r319408 - Preserve the "last diagnostic was suppressed" flag across SFINAE checks.

2017-11-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 30 00:18:21 2017
New Revision: 319408

URL: http://llvm.org/viewvc/llvm-project?rev=319408&view=rev
Log:
Preserve the "last diagnostic was suppressed" flag across SFINAE checks.

Sometimes we check the validity of some construct between producing a
diagnostic and producing its notes. Ideally, we wouldn't do that, but in
practice running code that "cannot possibly produce a diagnostic" in such a
situation should be safe, and reasonable factoring of some code requires it
with our current diagnostics infrastruture. If this does happen, a diagnostic
that's suppressed due to SFINAE should not cause notes connected to the prior
diagnostic to be suppressed.

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=319408&r1=319407&r2=319408&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Nov 30 00:18:21 2017
@@ -575,13 +575,15 @@ public:
   OverloadsShown getShowOverloads() const { return ShowOverloads; }
   
   /// \brief Pretend that the last diagnostic issued was ignored, so any
-  /// subsequent notes will be suppressed.
+  /// subsequent notes will be suppressed, or restore a prior ignoring
+  /// state after ignoring some diagnostics and their notes, possibly in
+  /// the middle of another diagnostic.
   ///
   /// This can be used by clients who suppress diagnostics themselves.
-  void setLastDiagnosticIgnored() {
+  void setLastDiagnosticIgnored(bool Ignored = true) {
 if (LastDiagLevel == DiagnosticIDs::Fatal)
   FatalErrorOccurred = true;
-LastDiagLevel = DiagnosticIDs::Ignored;
+LastDiagLevel = Ignored ? DiagnosticIDs::Ignored : DiagnosticIDs::Warning;
   }
 
   /// \brief Determine whether the previous diagnostic was ignored. This can

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=319408&r1=319407&r2=319408&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Nov 30 00:18:21 2017
@@ -7428,13 +7428,16 @@ public:
 unsigned PrevSFINAEErrors;
 bool PrevInNonInstantiationSFINAEContext;
 bool PrevAccessCheckingSFINAE;
+bool PrevLastDiagnosticIgnored;
 
   public:
 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
   : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
 PrevInNonInstantiationSFINAEContext(
   SemaRef.InNonInstantiationSFINAEContext),
-PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE)
+PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
+PrevLastDiagnosticIgnored(
+SemaRef.getDiagnostics().isLastDiagnosticIgnored())
 {
   if (!SemaRef.isSFINAEContext())
 SemaRef.InNonInstantiationSFINAEContext = true;
@@ -7446,6 +7449,8 @@ public:
   SemaRef.InNonInstantiationSFINAEContext
 = PrevInNonInstantiationSFINAEContext;
   SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
+  SemaRef.getDiagnostics().setLastDiagnosticIgnored(
+  PrevLastDiagnosticIgnored);
 }
 
 /// \brief Determine whether any SFINAE errors have been trapped.

Modified: cfe/trunk/test/CXX/drs/dr4xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr4xx.cpp?rev=319408&r1=319407&r2=319408&view=diff
==
--- cfe/trunk/test/CXX/drs/dr4xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr4xx.cpp Thu Nov 30 00:18:21 2017
@@ -22,6 +22,9 @@ namespace dr401 { // dr401: yes
   class B {
   protected:
 typedef int type; // expected-note {{protected}}
+#if __cplusplus == 199711L
+// expected-note@-2 {{protected}}
+#endif
   };
 
   class C {

Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=319408&r1=319407&r2=319408&view=diff
==
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Thu Nov 30 00:18:21 2017
@@ -658,3 +658,11 @@ namespace StringLiteralToCharAmbiguity {
   // expected-note@-5 {{candidate function}}
 #endif
 }
+
+namespace ProduceNotesAfterSFINAEFailure {
+  struct A {
+template A(T); // expected-warning 
0-1{{extension}}
+  };
+  void f(void*, A); // expected-note {{candidate function not viable}}
+  void g() { f(1, 2); } // expected-error {{no matching function}}
+

[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-11-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

This has been sitting in approved state for more than 2 months. As far as I can 
tell, it wasn't committed. Do you plan to commit this soon or are you 
abandoning it for some reason?


https://reviews.llvm.org/D36431



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


r319413 - [CodeGen] Add initial support for union members in TBAA

2017-11-30 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Thu Nov 30 01:26:39 2017
New Revision: 319413

URL: http://llvm.org/viewvc/llvm-project?rev=319413&view=rev
Log:
[CodeGen] Add initial support for union members in TBAA

The basic idea behind this patch is that since in strict aliasing
mode all accesses to union members require their outermost
enclosing union objects to be specified explicitly, then for a
couple given accesses to union members of the form

p->a.b.c...
q->x.y.z...

it is known they can only alias if both p and q point to the same
union type and offset ranges of members a.b.c... and x.y.z...
overlap. Note that the actual types of the members do not matter.

Specifically, in this patch we do the following:

* Make unions to be valid TBAA base access types. This enables
  generation of TBAA type descriptors for unions.

* Encode union types as structures with a single member of a
  special "union member" type. Currently we do not encode
  information about sizes of types, but conceptually such union
  members are considered to be of the size of the whole union.

* Encode accesses to direct and indirect union members, including
  member arrays, as accesses to these special members. All
  accesses to members of a union thus get the same offset, which
  is the offset of the union they are part of. This means the
  existing LLVM TBAA machinery is able to handle such accesses
  with no changes.

While this is already an improvement comparing to the current
situation, that is, representing all union accesses as may-alias
ones, there are further changes planned to complete the support
for unions. One of them is storing information about access sizes
so we can distinct accesses to non-overlapping union members,
including accesses to different elements of member arrays.
Another change is encoding type sizes in order to make it
possible to compute offsets within constant-indexed array
elements. These enhancements will be addressed with separate
patches.

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

Added:
cfe/trunk/test/CodeGen/tbaa-union.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.h
cfe/trunk/test/CodeGen/union-tbaa1.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=319413&r1=319412&r2=319413&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Nov 30 01:26:39 2017
@@ -3723,9 +3723,6 @@ LValue CodeGenFunction::EmitLValueForFie
   if (base.getTBAAInfo().isMayAlias() ||
   rec->hasAttr() || FieldType->isVectorType()) {
 FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
-  } else if (rec->isUnion()) {
-// TODO: Support TBAA for unions.
-FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
   } else {
 // If no base type been assigned for the base access, then try to generate
 // one for this base lvalue.
@@ -3736,16 +3733,26 @@ LValue CodeGenFunction::EmitLValueForFie
"Nonzero offset for an access with no base type!");
 }
 
-// Adjust offset to be relative to the base type.
-const ASTRecordLayout &Layout =
-getContext().getASTRecordLayout(field->getParent());
-unsigned CharWidth = getContext().getCharWidth();
-if (FieldTBAAInfo.BaseType)
-  FieldTBAAInfo.Offset +=
-  Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
+// All union members are encoded to be of the same special type.
+if (FieldTBAAInfo.BaseType && rec->isUnion())
+  FieldTBAAInfo = 
TBAAAccessInfo::getUnionMemberInfo(FieldTBAAInfo.BaseType,
+ FieldTBAAInfo.Offset,
+ FieldTBAAInfo.Size);
+
+// For now we describe accesses to direct and indirect union members as if
+// they were at the offset of their outermost enclosing union.
+if (!FieldTBAAInfo.isUnionMember()) {
+  // Adjust offset to be relative to the base type.
+  const ASTRecordLayout &Layout =
+  getContext().getASTRecordLayout(field->getParent());
+  unsigned CharWidth = getContext().getCharWidth();
+  if (FieldTBAAInfo.BaseType)
+FieldTBAAInfo.Offset +=
+Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
 
-// Update the final access type.
-FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+  // Update the final access type.
+  FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+}
   }
 
   Address addr = base.getAddress();

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=319413&r1=319412&r2=319413&view=diff
=

[PATCH] D39455: [CodeGen] Add initial support for union members in TBAA

2017-11-30 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319413: [CodeGen] Add initial support for union members in 
TBAA (authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D39455?vs=124726&id=124883#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39455

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
  cfe/trunk/lib/CodeGen/CodeGenTBAA.h
  cfe/trunk/test/CodeGen/tbaa-union.cpp
  cfe/trunk/test/CodeGen/union-tbaa1.c

Index: cfe/trunk/test/CodeGen/tbaa-union.cpp
===
--- cfe/trunk/test/CodeGen/tbaa-union.cpp
+++ cfe/trunk/test/CodeGen/tbaa-union.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for accesses to union
+// members.
+
+struct X {
+  int a, b;
+  int arr[3];
+  int c, d;
+};
+
+union U {
+  int i;
+  X x;
+  int j;
+};
+
+struct S {
+  U u, v;
+};
+
+union N {
+  int i;
+  S s;
+  int j;
+};
+
+struct R {
+  N n, m;
+};
+
+int f1(U *p) {
+// CHECK-LABEL: _Z2f1P1U
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_U_j:!.*]]
+  return p->j;
+}
+
+int f2(S *p) {
+// CHECK-LABEL: _Z2f2P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_u_i:!.*]]
+  return p->u.i;
+}
+
+int f3(S *p) {
+// CHECK-LABEL: _Z2f3P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_v_j:!.*]]
+  return p->v.j;
+}
+
+int f4(S *p) {
+// CHECK-LABEL: _Z2f4P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_u_x_b:!.*]]
+  return p->u.x.b;
+}
+
+int f5(S *p) {
+// CHECK-LABEL: _Z2f5P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_v_x_b:!.*]]
+  return p->v.x.b;
+}
+
+int f6(S *p) {
+// CHECK-LABEL: _Z2f6P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_u_x_arr:!.*]]
+  return p->u.x.arr[1];
+}
+
+int f7(S *p) {
+// CHECK-LABEL: _Z2f7P1S
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_S_v_x_arr:!.*]]
+  return p->v.x.arr[1];
+}
+
+int f8(N *p) {
+// CHECK-LABEL: _Z2f8P1N
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_N_s_v_x_c:!.*]]
+  return p->s.v.x.c;
+}
+
+int f9(R *p) {
+// CHECK-LABEL: _Z2f9P1R
+// CHECK: load i32, i32* {{.*}}, !tbaa [[TAG_R_m_s_v_x_c:!.*]]
+  return p->m.s.v.x.c;
+}
+
+// CHECK-DAG: [[TAG_U_j]] = !{[[TYPE_U:!.*]], [[TYPE_union_member:!.*]], i64 0}
+// CHECK-DAG: [[TAG_S_u_i]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TAG_S_u_x_b]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TAG_S_u_x_arr]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TAG_S_v_j]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 28}
+// CHECK-DAG: [[TAG_S_v_x_b]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 28}
+// CHECK-DAG: [[TAG_S_v_x_arr]] = !{[[TYPE_S:!.*]], [[TYPE_union_member]], i64 28}
+// CHECK-DAG: [[TAG_N_s_v_x_c]] = !{[[TYPE_N:!.*]], [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TAG_R_m_s_v_x_c]] = !{[[TYPE_R:!.*]], [[TYPE_union_member]], i64 56}
+// CHECK-DAG: [[TYPE_U]] = !{!"_ZTS1U", [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TYPE_S]] = !{!"_ZTS1S", [[TYPE_U]], i64 0, [[TYPE_U]], i64 28}
+// CHECK-DAG: [[TYPE_N]] = !{!"_ZTS1N", [[TYPE_union_member]], i64 0}
+// CHECK-DAG: [[TYPE_R]] = !{!"_ZTS1R", [[TYPE_N]], i64 0, [[TYPE_N]], i64 56}
+// CHECK-DAG: [[TYPE_union_member]] = !{!"union member", [[TYPE_char:!.*]], i64 0}
+// CHECK-DAG: [[TYPE_char]] = !{!"omnipotent char", {{.*}}, i64 0}
Index: cfe/trunk/test/CodeGen/union-tbaa1.c
===
--- cfe/trunk/test/CodeGen/union-tbaa1.c
+++ cfe/trunk/test/CodeGen/union-tbaa1.c
@@ -15,30 +15,32 @@
 // But no tbaa for the two stores:
 // CHECK: %uw[[UW1:[0-9]*]] = getelementptr
 // CHECK: store{{.*}}%uw[[UW1]]
-// CHECK: tbaa ![[OCPATH:[0-9]+]]
+// CHECK: tbaa [[TAG_vect32_union_member:![0-9]+]]
 // There will be a load after the store, and it will use tbaa. Make sure
 // the check-not above doesn't find it:
 // CHECK: load
   Tmp[*Index][0].uw = Arr[*Index][0] * Num;
 // CHECK: %uw[[UW2:[0-9]*]] = getelementptr
 // CHECK: store{{.*}}%uw[[UW2]]
-// CHECK: tbaa ![[OCPATH]]
+// CHECK: tbaa [[TAG_vect32_union_member]]
   Tmp[*Index][1].uw = Arr[*Index][1] * Num;
 // Same here, don't generate tbaa for the loads:
 // CHECK: %uh[[UH1:[0-9]*]] = bitcast %union.vect32
 // CHECK: %arrayidx[[AX1:[0-9]*]] = getelementptr{{.*}}%uh[[UH1]]
 // CHECK: load i16, i16* %arrayidx[[AX1]]
-// CHECK: tbaa ![[OCPATH]]
+// CHECK: tbaa [[TAG_vect32_union_member]]
 // CHECK: store
   Vec[0] = Tmp[*Index][0].uh[1];
 // CHECK: %uh[[UH2:[0-9]*]] = bitcast %union.vect32
 // CHECK: %arrayidx[[AX2:[0-9]*]] = getelementptr{{.*}}%uh[[UH2]]
 // CHECK: load i16, i16* %arrayidx[[AX2]]
-// CHECK: tbaa ![[OCPATH]]
+// CHECK: tbaa [[TAG_vect32_union_member]]
 // CHECK: store
   Vec[1] = Tmp[*Index][1].uh[1];
   bar(Tmp);
 }
 
-// CHECK-DAG: ![[CHAR:[0-9]+]] = !{!"omnipotent c

[PATCH] D38425: [clangd] Document highlights for clangd

2017-11-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/ClangdLSPServer.cpp:67
 );
+
   if (Params.rootUri && !Params.rootUri->file.empty())

malaperle wrote:
> extra line
Still there



Comment at: clangd/ClangdServer.cpp:513
+  auto FileContents = DraftMgr.getDraft(File);
+  assert(FileContents.Draft &&
+ "findDocumentHighlights is called for non-added document");

Other functions don't crash in this case anymore, we should follow the same 
pattern here (see `findDefinitions` for an example)



Comment at: clangd/ClangdServer.cpp:524
+if (!AST)
+  return;
+Result = clangd::findDocumentHighlights(*AST, Pos, Logger);

We should return an error this case.



Comment at: clangd/ClangdUnit.cpp:1062
+
+  DocumentHighlight getDocumentHighlight(SourceRange SR,
+ DocumentHighlightKind Kind) {

This function should be private.



Comment at: clangd/ClangdUnit.cpp:1096
+  Range R = {Begin, End};
+  Location L;
+  if (const FileEntry *F =

We should not return default-initialized `Locations` from this function.
Return `llvm::Optional` and handle the case when `getFileEntryForID` 
returns null by returning `llvm::None`.



Comment at: clangd/ClangdUnit.cpp:1165
 
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
+ DeclMacrosFinder, IndexOpts);

Let's add a comment that we don't currently handle macros. It's ok for the 
first iteration, having `documentHighlights` for `Decl`s is useful enough to 
get it in.



Comment at: clangd/Protocol.h:621
+const DocumentHighlight &RHS) {
+return std::tie(LHS.range) < std::tie(RHS.range);
+  }

Please also compare `kind` here, to make this operator consistent with 
`operator==`.
`std::tie(LHS.range, LHS.kind) < std::tie(RHS.range,  RHS.kind)` should work. 
If it doesn't, converting enums to int should help: `std::tie(LHS.range, 
int(LHS.kind)) < std::tie(RHS.range,  int(RHS.kind))`



Comment at: test/clangd/initialize-params-invalid.test:23
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT: "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {

NIT: Misindent



Comment at: test/clangd/initialize-params.test:23
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT: "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {

NIT: Misindent


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


[PATCH] D40640: Fix code completion crash with unresolved member expr and explicit base

2017-11-30 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv created this revision.

This is actually a failing assert. When doing object argument
initialization, it is valid to have e.g. 'this' as a base in a member
access expression (which is a prvalue). It's also possible to have a
scope specifier as part of the member expression, in which case a base
that is an actual lvalue gets wrapped in an ImplicitCastExpr, which in
turn is an rvalue.


https://reviews.llvm.org/D40640

Files:
  lib/Sema/SemaOverload.cpp
  test/CodeCompletion/member-access.cpp

Index: test/CodeCompletion/member-access.cpp
===
--- test/CodeCompletion/member-access.cpp
+++ test/CodeCompletion/member-access.cpp
@@ -42,10 +42,19 @@
   static void foo(bool);
 };
 
-struct Bar {
+struct Bar: Foo {
   void foo(bool param) {
 Foo::foo(  );// unresolved member expression with an implicit base
   }
+
+  void mooze(bool param) {
+this->Foo::foo(  );// unresolved member expression with an explicit base
+  }
+
+  void mooze(bool param, int anotherParam) {
+Bar *that = new Bar;
+that->Foo::foo(  );// unresolved member expression with an explicit base wrapped in a ImplicitCastExpr
+  }
 };
 
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
@@ -66,6 +75,8 @@
 
 // Make sure this also doesn't crash
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:47:14 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:51:21 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:56:21 %s
 
 
 template
@@ -100,8 +111,8 @@
 // CHECK-CC2: overload1 : [#void#]overload1(<#const T &#>)
 // CHECK-CC2: overload1 : [#void#]overload1(<#const S &#>)
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:92:10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:93:12 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:103:10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:104:12 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
 }
 
 
@@ -118,8 +129,8 @@
 // CHECK-CC3: overload1 : [#void#]overload1(<#const int &#>)
 // CHECK-CC3: overload1 : [#void#]overload1(<#const double &#>)
 
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:110:10 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:111:12 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:121:10 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:122:12 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 }
 
 template 
@@ -133,17 +144,17 @@
 // CHECK-CC4: BaseTemplate : BaseTemplate::
 // CHECK-CC4: baseTemplateField : [#int#]baseTemplateField
 // CHECK-CC4: baseTemplateFunction : [#int#]baseTemplateFunction()
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:132:8 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:143:8 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
 o2.baseTemplateField;
 // CHECK-CC5: BaseTemplate : BaseTemplate::
 // CHECK-CC5: baseTemplateField : [#T#]baseTemplateField
 // CHECK-CC5: baseTemplateFunction : [#T#]baseTemplateFunction()
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:137:8 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:148:8 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
 this->o1;
 // CHECK-CC6: [#void#]function()
 // CHECK-CC6: o1 : [#BaseTemplate#]o1
 // CHECK-CC6: o2 : [#BaseTemplate#]o2
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:153:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
   }
 
   static void staticFn(T &obj);
@@ -160,7 +171,7 @@
 // CHECK-CC7: o2 : [#BaseTemplate#]o2
 // CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>)
 // CHECK-CC7: Template : Template
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:167:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   typename Template::Nested m;
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:175:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
 }
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5023,14 +5023,9 @@
   ImplicitConversionSequence ICS;
 
   // We need to have an object of class type.
-  if (const PointerType *PT = FromType->getAs()) {
+  if (const PointerType *PT = FromType->getAs())
 

[PATCH] D40562: [Sema] Ignore decls in namespaces when global decls are not wanted.

2017-11-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D40562#939950, @arphaman wrote:

> This change breaks cached completions for declarations in namespaces in 
> libclang. What exactly are you trying to achieve here? We could introduce 
> another flag maybe.


Am I right to assume this cache is there to reduce the amount of `Decl`s we 
need to deserialize from `Preamble`s? Maybe we could fix the cache to also 
include namespace-level `Decl`s? It should improve performance of the cached 
completions.

But for a quick workaround we could introduce a separate flag.


https://reviews.llvm.org/D40562



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


[PATCH] D40563: [SemaCodeComplete] Allow passing out scope specifiers in qualified-id completions via completion context.

2017-11-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:4609
 
+  if (SS.isInvalid()) {
+CodeCompletionContext CC(CodeCompletionContext::CCC_Name);

ioeric wrote:
> ilya-biryukov wrote:
> > ilya-biryukov wrote:
> > > Why do we alter this code path?
> > Maybe we should add a test or provide examples why the current code does 
> > not work for us?
> There is no existing unit test for CodeCompletion, and there is no much to 
> test here either. I added a comment with example for this.
Makes sense, thanks for the explanation.


https://reviews.llvm.org/D40563



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


[PATCH] D40642: clang-format: [JS] do not wrap after async/await.

2017-11-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added subscribers: cfe-commits, klimek.

Otherwise automatic semicolon insertion can trigger, i.e. wrapping
produces invalid syntax.


Repository:
  rC Clang

https://reviews.llvm.org/D40642

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1152,6 +1152,11 @@
"const y = 3\n",
"const x = (   5 +9)\n"
"const y = 3\n");
+  // Ideally the foo() bit should be indented relative to the async function().
+  verifyFormat("async function\n"
+   "foo() {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2701,12 +2701,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, 
tok::kw_continue,
-tok::kw_break, tok::kw_throw, 
Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract,
-Keywords.kw_get, Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
+tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
+tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
+Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Left.Tok.getIdentifierInfo() &&
 Right.startsSequence(tok::l_square, tok::r_square))


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1152,6 +1152,11 @@
"const y = 3\n",
"const x = (   5 +9)\n"
"const y = 3\n");
+  // Ideally the foo() bit should be indented relative to the async function().
+  verifyFormat("async function\n"
+   "foo() {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2701,12 +2701,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, tok::kw_continue,
-tok::kw_break, tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract,
-Keywords.kw_get, Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
+tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
+tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
+Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Left.Tok.getIdentifierInfo() &&
 Right.startsSequence(tok::l_square, tok::r_square))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40643: [libclang] Add function to get the buffer for a file

2017-11-30 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv created this revision.

This can be used by clients in conjunction with an offset returned by
e.g. clang_getFileLocation. Now those clients do not need to also
open/read the file.


https://reviews.llvm.org/D40643

Files:
  include/clang-c/Index.h
  tools/libclang/CIndex.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4151,6 +4151,27 @@
   return const_cast(FMgr.getFile(file_name));
 }
 
+const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
+  size_t *size) {
+  if (isNotUsableTU(TU)) {
+LOG_BAD_TU(TU);
+return nullptr;
+  }
+
+  const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
+  FileID fid = SM.translateFile(static_cast(file));
+  bool Invalid = true;
+  llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
+  if (Invalid) {
+if (size)
+  *size = 0;
+return nullptr;
+  }
+  if (size)
+*size = buf->getBufferSize();
+  return buf->getBufferStart();
+}
+
 unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
 CXFile file) {
   if (isNotUsableTU(TU)) {
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -394,6 +394,21 @@
 const char *file_name);
 
 /**
+ * \brief Retrieve the buffer associated with the given file.
+ *
+ * \param tu the translation unit
+ *
+ * \param file the file for which to retrieve the buffer.
+ *
+ * \param size [out] if non-NULL, will be set to the size of the buffer.
+ *
+ * \returns a pointer to the buffer in memory that holds the contents of
+ * \p file, or a NULL pointer when the file is not loaded.
+ */
+CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
+ CXFile file, size_t *size);
+
+/**
  * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
  * or they are both NULL.
  */


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4151,6 +4151,27 @@
   return const_cast(FMgr.getFile(file_name));
 }
 
+const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
+  size_t *size) {
+  if (isNotUsableTU(TU)) {
+LOG_BAD_TU(TU);
+return nullptr;
+  }
+
+  const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
+  FileID fid = SM.translateFile(static_cast(file));
+  bool Invalid = true;
+  llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
+  if (Invalid) {
+if (size)
+  *size = 0;
+return nullptr;
+  }
+  if (size)
+*size = buf->getBufferSize();
+  return buf->getBufferStart();
+}
+
 unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
 CXFile file) {
   if (isNotUsableTU(TU)) {
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -394,6 +394,21 @@
 const char *file_name);
 
 /**
+ * \brief Retrieve the buffer associated with the given file.
+ *
+ * \param tu the translation unit
+ *
+ * \param file the file for which to retrieve the buffer.
+ *
+ * \param size [out] if non-NULL, will be set to the size of the buffer.
+ *
+ * \returns a pointer to the buffer in memory that holds the contents of
+ * \p file, or a NULL pointer when the file is not loaded.
+ */
+CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
+ CXFile file, size_t *size);
+
+/**
  * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
  * or they are both NULL.
  */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40642: clang-format: [JS] do not wrap after async/await.

2017-11-30 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rC Clang

https://reviews.llvm.org/D40642



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


r319415 - clang-format: [JS] do not wrap after async/await.

2017-11-30 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Nov 30 02:25:17 2017
New Revision: 319415

URL: http://llvm.org/viewvc/llvm-project?rev=319415&view=rev
Log:
clang-format: [JS] do not wrap after async/await.

Summary:
Otherwise automatic semicolon insertion can trigger, i.e. wrapping
produces invalid syntax.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=319415&r1=319414&r2=319415&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 30 02:25:17 2017
@@ -2701,12 +2701,12 @@ bool TokenAnnotator::canBreakBefore(cons
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, 
tok::kw_continue,
-tok::kw_break, tok::kw_throw, 
Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract,
-Keywords.kw_get, Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
+tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
+tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
+Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Left.Tok.getIdentifierInfo() &&
 Right.startsSequence(tok::l_square, tok::r_square))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=319415&r1=319414&r2=319415&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Nov 30 02:25:17 2017
@@ -1152,6 +1152,11 @@ TEST_F(FormatTestJS, WrapRespectsAutomat
"const y = 3\n",
"const x = (   5 +9)\n"
"const y = 3\n");
+  // Ideally the foo() bit should be indented relative to the async function().
+  verifyFormat("async function\n"
+   "foo() {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {


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


[PATCH] D40642: clang-format: [JS] do not wrap after async/await.

2017-11-30 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319415: clang-format: [JS] do not wrap after async/await. 
(authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D40642

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2701,12 +2701,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, 
tok::kw_continue,
-tok::kw_break, tok::kw_throw, 
Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract,
-Keywords.kw_get, Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
+tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
+tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
+Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Left.Tok.getIdentifierInfo() &&
 Right.startsSequence(tok::l_square, tok::r_square))
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1152,6 +1152,11 @@
"const y = 3\n",
"const x = (   5 +9)\n"
"const y = 3\n");
+  // Ideally the foo() bit should be indented relative to the async function().
+  verifyFormat("async function\n"
+   "foo() {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2701,12 +2701,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, tok::kw_continue,
-tok::kw_break, tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract,
-Keywords.kw_get, Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
+tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
+tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
+Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Left.Tok.getIdentifierInfo() &&
 Right.startsSequence(tok::l_square, tok::r_square))
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1152,6 +1152,11 @@
"const y = 3\n",
"const x = (   5 +9)\n"
"const y = 3\n");
+  // Ideally the foo() bit should be indented relative to the async function().
+  verifyFormat("async function\n"
+   "foo() {}",
+   getGoogleJSStyleWithColumns(10));
+  verifyFormat("await theReckoning;", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-11-30 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 124903.
erikjv added a comment.

I moved all code to the TextDiagnostics, so all other interfaces still get byte 
offsets.


https://reviews.llvm.org/D33765

Files:
  lib/Frontend/TextDiagnostic.cpp
  test/Misc/diag-utf8.cpp


Index: test/Misc/diag-utf8.cpp
===
--- /dev/null
+++ test/Misc/diag-utf8.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Foo { int member; };
+
+void f(Foo foo)
+{
+"ideeen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:7:14: error: invalid 
operands to binary expression ('const char *' and 'Foo')
+"ideëen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:8:14: error: invalid 
operands to binary expression ('const char *' and 'Foo')
+"idez̈en" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:9:14: error: invalid 
operands to binary expression ('const char *' and 'Foo')
+}
Index: lib/Frontend/TextDiagnostic.cpp
===
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Locale.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Unicode.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -818,6 +819,28 @@
   if (DiagOpts->ShowColumn)
 // Compute the column number.
 if (unsigned ColNo = PLoc.getColumn()) {
+  // Correct the column number for multi-byte UTF-8 code-points.
+  bool Invalid = false;
+  StringRef BufData = Loc.getBufferData(&Invalid);
+  if (!Invalid) {
+const char *BufStart = BufData.data();
+const char *BufEnd = BufStart + BufData.size();
+
+// Decompose the location into a FID/Offset pair.
+std::pair LocInfo = Loc.getDecomposedLoc();
+FileID FID = LocInfo.first;
+const SourceManager &SM = Loc.getManager();
+const char *LineStart =
+BufStart +
+SM.getDecomposedLoc(SM.translateLineCol(FID, LineNo, 1)).second;
+if (LineStart + ColNo < BufEnd) {
+  StringRef SourceLine(LineStart, ColNo);
+  int CorrectedColNo = llvm::sys::unicode::columnWidthUTF8(SourceLine);
+  if (CorrectedColNo != -1)
+ColNo = unsigned(CorrectedColNo);
+}
+  }
+
   if (DiagOpts->getFormat() == DiagnosticOptions::MSVC) {
 OS << ',';
 // Visual Studio 2010 or earlier expects column number to be off by one


Index: test/Misc/diag-utf8.cpp
===
--- /dev/null
+++ test/Misc/diag-utf8.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Foo { int member; };
+
+void f(Foo foo)
+{
+"ideeen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:7:14: error: invalid operands to binary expression ('const char *' and 'Foo')
+"ideëen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:8:14: error: invalid operands to binary expression ('const char *' and 'Foo')
+"idez̈en" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:9:14: error: invalid operands to binary expression ('const char *' and 'Foo')
+}
Index: lib/Frontend/TextDiagnostic.cpp
===
--- lib/Frontend/TextDiagnostic.cpp
+++ lib/Frontend/TextDiagnostic.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Locale.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Unicode.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -818,6 +819,28 @@
   if (DiagOpts->ShowColumn)
 // Compute the column number.
 if (unsigned ColNo = PLoc.getColumn()) {
+  // Correct the column number for multi-byte UTF-8 code-points.
+  bool Invalid = false;
+  StringRef BufData = Loc.getBufferData(&Invalid);
+  if (!Invalid) {
+const char *BufStart = BufData.data();
+const char *BufEnd = BufStart + BufData.size();
+
+// Decompose the location into a FID/Offset pair.
+std::pair LocInfo = Loc.getDecomposedLoc();
+FileID FID = LocInfo.first;
+const SourceManager &SM = Loc.getManager();
+const char *LineStart =
+BufStart +
+SM.getDecomposedLoc(SM.translateLineCol(FID, LineNo, 1)).second;
+if (LineStart + ColNo < BufEnd) {
+  StringRef SourceLine(LineStart, ColNo);
+  int CorrectedColNo = llvm::sys::unicode::columnWidthUTF8(SourceLine);
+  if (CorrectedColNo != -1)
+ColNo = unsigned(CorrectedColNo);
+}
+  }
+
   if (DiagOpts->getFormat() == DiagnosticOptions::MSVC) {
 OS << ',';
 // Visual Studio 2010 or earlier expects column number to be off by one
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40643: [libclang] Add function to get the buffer for a file

2017-11-30 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 124904.
erikjv added a comment.

Bumped the CINDEX_VERSION_MINOR.


https://reviews.llvm.org/D40643

Files:
  include/clang-c/Index.h
  tools/libclang/CIndex.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4151,6 +4151,27 @@
   return const_cast(FMgr.getFile(file_name));
 }
 
+const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
+  size_t *size) {
+  if (isNotUsableTU(TU)) {
+LOG_BAD_TU(TU);
+return nullptr;
+  }
+
+  const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
+  FileID fid = SM.translateFile(static_cast(file));
+  bool Invalid = true;
+  llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
+  if (Invalid) {
+if (size)
+  *size = 0;
+return nullptr;
+  }
+  if (size)
+*size = buf->getBufferSize();
+  return buf->getBufferStart();
+}
+
 unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
 CXFile file) {
   if (isNotUsableTU(TU)) {
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 43
+#define CINDEX_VERSION_MINOR 44
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -394,6 +394,21 @@
 const char *file_name);
 
 /**
+ * \brief Retrieve the buffer associated with the given file.
+ *
+ * \param tu the translation unit
+ *
+ * \param file the file for which to retrieve the buffer.
+ *
+ * \param size [out] if non-NULL, will be set to the size of the buffer.
+ *
+ * \returns a pointer to the buffer in memory that holds the contents of
+ * \p file, or a NULL pointer when the file is not loaded.
+ */
+CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
+ CXFile file, size_t *size);
+
+/**
  * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
  * or they are both NULL.
  */


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4151,6 +4151,27 @@
   return const_cast(FMgr.getFile(file_name));
 }
 
+const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
+  size_t *size) {
+  if (isNotUsableTU(TU)) {
+LOG_BAD_TU(TU);
+return nullptr;
+  }
+
+  const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
+  FileID fid = SM.translateFile(static_cast(file));
+  bool Invalid = true;
+  llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid);
+  if (Invalid) {
+if (size)
+  *size = 0;
+return nullptr;
+  }
+  if (size)
+*size = buf->getBufferSize();
+  return buf->getBufferStart();
+}
+
 unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
 CXFile file) {
   if (isNotUsableTU(TU)) {
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 43
+#define CINDEX_VERSION_MINOR 44
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -394,6 +394,21 @@
 const char *file_name);
 
 /**
+ * \brief Retrieve the buffer associated with the given file.
+ *
+ * \param tu the translation unit
+ *
+ * \param file the file for which to retrieve the buffer.
+ *
+ * \param size [out] if non-NULL, will be set to the size of the buffer.
+ *
+ * \returns a pointer to the buffer in memory that holds the contents of
+ * \p file, or a NULL pointer when the file is not loaded.
+ */
+CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
+ CXFile file, size_t *size);
+
+/**
  * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
  * or they are both NULL.
  */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319420 - [ARM] disable FPU features when using soft floating point.

2017-11-30 Thread Keith Walker via cfe-commits
Author: kwalker
Date: Thu Nov 30 03:38:56 2017
New Revision: 319420

URL: http://llvm.org/viewvc/llvm-project?rev=319420&view=rev
Log:
[ARM] disable FPU features when using soft floating point.

To be compatible with GCC if soft floating point is in effect any FPU
specified is effectively ignored, eg,

  -mfloat-abi=soft -fpu=neon

If any floating point features which require FPU hardware are enabled
they must be disable.

There was some support for doing this for NEON, but it did not handle
VFP, nor did it prevent the backend from emitting the build attribute
Tag_FP_arch describing the generated code as using the floating point
hardware if a FPU was specified (even though soft float does not use
the FPU).

Disabling the hardware floating point features for targets which are
compiling for soft float has meant that some tests which were incorrectly
checking for hardware support also needed to be updated. In such cases,
where appropriate the tests have been updated to check compiling for
soft float and a non-soft float variant (usually softfp). This was
usually because the target specified in the test defaulted to soft float.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Driver/arm-dotprod.c
cfe/trunk/test/Driver/arm-mfpu.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=319420&r1=319419&r2=319420&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Nov 30 03:38:56 2017
@@ -391,12 +391,22 @@ void arm::getARMTargetFeatures(const Too
   } else if (HDivArg)
 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features);
 
-  // Setting -msoft-float effectively disables NEON because of the GCC
-  // implementation, although the same isn't true of VFP or VFP3.
+  // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC
+  // ignores the -mfpu options in this case).
+  // Note that the ABI can also be set implicitly by the target selected.
   if (ABI == arm::FloatABI::Soft) {
-Features.push_back("-neon");
-// Also need to explicitly disable features which imply NEON.
-Features.push_back("-crypto");
+llvm::ARM::getFPUFeatures(llvm::ARM::FK_NONE, Features);
+
+// Disable hardware FP features which have been enabled.
+// FIXME: Disabling vfp2 and neon should be enough as all the other
+//features are dependant on these 2 features in LLVM. However
+//there is currently no easy way to test this in clang, so for
+//now just be explicit and disable all known dependent features
+//as well.
+for (std::string Feature : {"vfp2", "vfp3", "vfp4", "fp-armv8", "fullfp16",
+"neon", "crypto", "dotprod"})
+  if (std::find(std::begin(Features), std::end(Features), "+" + Feature) 
!= std::end(Features))
+Features.push_back("-" + Feature);
   }
 
   // En/disable crc code generation.

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=319420&r1=319419&r2=319420&view=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Thu Nov 30 03:38:56 2017
@@ -284,13 +284,13 @@
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-BE-V82A-THUMB %s
 // CHECK-BE-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.2a-{{.*}}" 
"-target-cpu" "generic"
 
-// RUN: %clang -target armv8a -march=armv8.2-a+fp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-V82A-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" 
"generic" {{.*}}"-target-feature" "+fullfp16"
 
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
-// RUN: %clang -target armv8a -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
-// RUN: %clang -target armv8a -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 
2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex

[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319420: [ARM] disable FPU features when using soft floating 
point. (authored by kwalker).

Changed prior to commit:
  https://reviews.llvm.org/D40256?vs=124579&id=124905#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40256

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c
  test/Driver/arm-mfpu.c
  test/Preprocessor/arm-target-features.c

Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -391,12 +391,22 @@
   } else if (HDivArg)
 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features);
 
-  // Setting -msoft-float effectively disables NEON because of the GCC
-  // implementation, although the same isn't true of VFP or VFP3.
+  // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC
+  // ignores the -mfpu options in this case).
+  // Note that the ABI can also be set implicitly by the target selected.
   if (ABI == arm::FloatABI::Soft) {
-Features.push_back("-neon");
-// Also need to explicitly disable features which imply NEON.
-Features.push_back("-crypto");
+llvm::ARM::getFPUFeatures(llvm::ARM::FK_NONE, Features);
+
+// Disable hardware FP features which have been enabled.
+// FIXME: Disabling vfp2 and neon should be enough as all the other
+//features are dependant on these 2 features in LLVM. However
+//there is currently no easy way to test this in clang, so for
+//now just be explicit and disable all known dependent features
+//as well.
+for (std::string Feature : {"vfp2", "vfp3", "vfp4", "fp-armv8", "fullfp16",
+"neon", "crypto", "dotprod"})
+  if (std::find(std::begin(Features), std::end(Features), "+" + Feature) != std::end(Features))
+Features.push_back("-" + Feature);
   }
 
   // En/disable crc code generation.
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -284,13 +284,13 @@
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A-THUMB %s
 // CHECK-BE-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.2a-{{.*}}" "-target-cpu" "generic"
 
-// RUN: %clang -target armv8a -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
 
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
-// RUN: %clang -target armv8a -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
-// RUN: %clang -target armv8a -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
 // CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "-fullfp16"
 
Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target arm-linux-eabi %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-DEFAULT: "-target-feature" "+soft-float-abi"
 // CHECK-DEFAULT-NOT: "-target-feature" "+vfp2"
 // CHECK-DEFAULT-NOT: "-target-feature" "+vfp3"
 // CHECK-DEFAULT-NOT: "-target-feature" "+d16"
@@ -19,6 +21,10 @@
 
 // RUN: %clang -target arm-linux-eabi -mfpu=vfp %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-VFP %s
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp %s -mfloat-abi=soft -### -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SOFT-ABI-FP %s
+// CHECK-VFP-NOT: "-target-feature" "+soft-float"
+// CHECK-VFP: "-target-feature" "+soft-float-abi"
 // CHECK-VFP: "-target-feature" "+vfp2"
 // CHECK-VFP: "-target-feature" "-vfp3"
 // CHECK-VFP: "-target-feature" "-vfp4"
@@ -29,13 +35,21 @@
 // RUN:   | FileCheck --check-prefix=CHECK-VFP3 %s
 // RUN: %clang -target arm-linux-eabi -mfpu=vfpv3 %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-

r319425 - Revert [ARM] disable FPU features when using soft floating point.

2017-11-30 Thread Keith Walker via cfe-commits
Author: kwalker
Date: Thu Nov 30 04:05:18 2017
New Revision: 319425

URL: http://llvm.org/viewvc/llvm-project?rev=319425&view=rev
Log:
Revert [ARM] disable FPU features when using soft floating point.

This reverts r319420
It is failing the test Driver/arm-mfpu.c so reverting while I investigate the 
failure.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Driver/arm-dotprod.c
cfe/trunk/test/Driver/arm-mfpu.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=319425&r1=319424&r2=319425&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Nov 30 04:05:18 2017
@@ -391,22 +391,12 @@ void arm::getARMTargetFeatures(const Too
   } else if (HDivArg)
 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features);
 
-  // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC
-  // ignores the -mfpu options in this case).
-  // Note that the ABI can also be set implicitly by the target selected.
+  // Setting -msoft-float effectively disables NEON because of the GCC
+  // implementation, although the same isn't true of VFP or VFP3.
   if (ABI == arm::FloatABI::Soft) {
-llvm::ARM::getFPUFeatures(llvm::ARM::FK_NONE, Features);
-
-// Disable hardware FP features which have been enabled.
-// FIXME: Disabling vfp2 and neon should be enough as all the other
-//features are dependant on these 2 features in LLVM. However
-//there is currently no easy way to test this in clang, so for
-//now just be explicit and disable all known dependent features
-//as well.
-for (std::string Feature : {"vfp2", "vfp3", "vfp4", "fp-armv8", "fullfp16",
-"neon", "crypto", "dotprod"})
-  if (std::find(std::begin(Features), std::end(Features), "+" + Feature) 
!= std::end(Features))
-Features.push_back("-" + Feature);
+Features.push_back("-neon");
+// Also need to explicitly disable features which imply NEON.
+Features.push_back("-crypto");
   }
 
   // En/disable crc code generation.

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=319425&r1=319424&r2=319425&view=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Thu Nov 30 04:05:18 2017
@@ -284,13 +284,13 @@
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-BE-V82A-THUMB %s
 // CHECK-BE-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.2a-{{.*}}" 
"-target-cpu" "generic"
 
-// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-V82A-FP16 %s
+// RUN: %clang -target armv8a -march=armv8.2-a+fp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" 
"generic" {{.*}}"-target-feature" "+fullfp16"
 
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
-// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
-// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 
2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
+// RUN: %clang -target armv8a -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
+// RUN: %clang -target armv8a -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | 
FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" 
{{.*}}"-target-feature" "+fullfp16"
 // CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" 
{{.*}}"-target-feature" "-fullfp16"
 

Modified: cfe/trunk/test/Driver/arm-dotprod.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-dotprod.c?rev=319425&r1=319424&r2=319425&view=diff
==
--- cfe/trunk/test/Driver/arm-dotprod.c (original)
+++ cfe/trunk/test/Driver/arm-dotprod.c Thu Nov 30 04:05:18 2017
@@ -4,21 +4,8 @@
 // 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-linux-eabi -march=armv8.2a+dotprod %s 2>&1 | 
FileCheck %s
-// RUN: %clang -### -target arm-linux-eabi -march=armv8.3a+dotprod %s 2>&1 | 
FileCheck %s
-// RUN: %clang -### -ta

[PATCH] D40621: MS ABI: Treat explicit instantiation definitions of dllimport function templates as explicit instantiation decls (PR35435)

2017-11-30 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Looks good to me 2.


Repository:
  rL LLVM

https://reviews.llvm.org/D40621



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


[PATCH] D40605: Better trade-off for excess characters vs. staying within the column limits.

2017-11-30 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a subscriber: djasper.
krasimir added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1422
+   Strict);
+}
   }

The problem here is that we're calling breakProtrudingToken 3 times more than 
we used to. Seems like such a waste.
@djasper: do you think this is fine?



Comment at: lib/Format/ContinuationIndenter.cpp:1519
   if (!Token)
-return 0;
+return {0, true};
   assert(Token->getLineCount() > 0);

Why we return true here?



Comment at: lib/Format/ContinuationIndenter.cpp:1773
 Style.PenaltyExcessCharacter;
 if (NewBreakPenalty < ExcessCharactersPenalty) {
   Reflow = false;

Shouldn't we also be messing up something here in this patch?


Repository:
  rC Clang

https://reviews.llvm.org/D40605



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


[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Thanks you very much for this patch, JSON parsing now looks better than ever!
LGTM. (Just a few minor NITs).




Comment at: clangd/JSONExpr.h:71
+// The convention is to have a deserialize function findable via ADL:
+// deserialize(const json::Expr&, T&)->bool
+// Deserializers are provided for:

The name `deserialize` may be a bit too general and prone to clashes with other 
code. Maybe choosing something a bit more specific like `json_deserialize` is a 
better option.
On the other hand, we do the SFINAE trick to check the types are correct in 
`Expr` constructor, so we should be fine either way.



Comment at: clangd/JSONExpr.h:512
+  if (auto *O = E.asObject()) {
+for (const auto &KV : *O)
+  if (!deserialize(KV.second, Out[llvm::StringRef(KV.first)]))

Maybe also call `Out.clear()` to be consistent with `deserialize(..., vector)`?



Comment at: clangd/JSONExpr.h:547
+
+  const json::obj *O;
+};

Maybe make this field private?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40596



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


[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D40588



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


[PATCH] D40605: Better trade-off for excess characters vs. staying within the column limits.

2017-11-30 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1422
+   Strict);
+}
   }

krasimir wrote:
> The problem here is that we're calling breakProtrudingToken 3 times more than 
> we used to. Seems like such a waste.
> @djasper: do you think this is fine?
If we're in DryRun mode (all through the optimization phase) and we don't 
actually leave around excess characters, we call this exactly once per 
protruding token, so the vast majority of cases will see no change.

We'll always have an additional call in non-dry-run mode, but I think that 
completely doesn't matter, and we'll have a second call if we actually do leave 
around excess characters - note that this only happens when the excess 
character penalty is low enough, so it won't actually affect the normal LLVM / 
Google styles.



Comment at: lib/Format/ContinuationIndenter.cpp:1519
   if (!Token)
-return 0;
+return {0, true};
   assert(Token->getLineCount() > 0);

krasimir wrote:
> Why we return true here?
Argh, because I first had inverted the concept and changed it later - thanks 
for catching, will fix.



Comment at: lib/Format/ContinuationIndenter.cpp:1773
 Style.PenaltyExcessCharacter;
 if (NewBreakPenalty < ExcessCharactersPenalty) {
   Reflow = false;

krasimir wrote:
> Shouldn't we also be messing up something here in this patch?
This just switches reflowing to false, which will keep the original line break. 
This basically figures out whether we will later be able to break. That might 
lead to a non-perfect solution later, as we might reflow ourselves into a 
situation where we have to leave excess characters around, which we could have 
avoided if we kept under the limit, but I do not think that matteres in an 
observable way.


Repository:
  rC Clang

https://reviews.llvm.org/D40605



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


[PATCH] D40643: [libclang] Add function to get the buffer for a file

2017-11-30 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D40643



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


[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-11-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: dcoughlin, sbaranga, jmolloy.
aaron.ballman added a comment.

Added @dcoughlin for opinions about the static analyzer, added @sbaranga and 
@jmolloy for questions about NEON.




Comment at: include/clang/Basic/Attr.td:602
 def AnalyzerNoReturn : InheritableAttr {
-  let Spellings = [GNU<"analyzer_noreturn">];
+  let Spellings = [Clang<"analyzer_noreturn">];
   let Documentation = [Undocumented];

rsmith wrote:
> Hmm, should the clang static analyzer reuse the `clang::` namespace, or 
> should it get its own?
Good question, I don't have strong opinions on the answer here, but perhaps 
@dcoughlin does?

If we want to use a separate namespace for the analyzer, would we want to use 
that same namespace for any clang-tidy specific attributes? Or should 
clang-tidy get its own namespace? (Do we ever plan to execute clang-tidy 
through the clang driver? That might change our answer.)



Comment at: include/clang/Basic/Attr.td:649
 def Availability : InheritableAttr {
-  let Spellings = [GNU<"availability">];
+  let Spellings = [Clang<"availability">];
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,

rsmith wrote:
> Does the custom parsing for this work for the C++11 attribute syntax?
Nope; I'll do this one separately (and make sure no other attributes similarly 
use custom parsing).



Comment at: include/clang/Basic/Attr.td:1218-1228
 def NeonPolyVectorType : TypeAttr {
-  let Spellings = [GNU<"neon_polyvector_type">];
+  let Spellings = [Clang<"neon_polyvector_type">];
   let Args = [IntArgument<"NumElements">];
   let Documentation = [Undocumented];
 }
 
 def NeonVectorType : TypeAttr {

rsmith wrote:
> I *think* these are a Clang invention rather than part of the ARM NEON 
> intrinsics specification, but perhaps you could ask someone from ARM to 
> confirm that.
@sbaranga or @jmolloy -- do you happen to know the answer to this, or know 
someone who does?


https://reviews.llvm.org/D40625



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


[PATCH] D40651: Implement most of P0451 - Constexpr for std::complex

2017-11-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

This patch implements most of https://wg21.link/P0451r1 - the notable exception 
being division.
The current implementation of complex division in libc++ uses `logb`, `fmax`, 
and a couple of other primitives that are not constexpr. The paper has some 
approaches for dealing with this, but I haven't implemented those yet. I wanted 
to get all the mechanical bits out first.

Note that there are tests for division being constexpr; they currently fail.


https://reviews.llvm.org/D40651

Files:
  include/complex
  test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
  
test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
  
test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
  test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
  
test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
  test/std/numerics/complex.number/complex.members/real_imag.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
  test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
  test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
  test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
  test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp
  test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp
  test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
  test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
  test/std/numerics/complex.number/complex.value.ops/real.pass.cpp

Index: test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
===
--- test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
+++ test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
@@ -12,16 +12,30 @@
 // template
 //   T
 //   real(const complex& x);
+//   constexpr in C++20
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
+TEST_CONSTEXPR bool
+constexpr_test()
+{
+std::complex z(1.5, 2.5);
+return real(z) == 1.5;
+}
+
+template 
 void
 test()
 {
 std::complex z(1.5, 2.5);
 assert(real(z) == 1.5);
+#if TEST_STD_VER > 17
+static_assert(constexpr_test(), "");
+#endif
 }
 
 int main()
Index: test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
===
--- test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
+++ test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
@@ -12,13 +12,24 @@
 // template
 //   complex
 //   proj(const complex& x);
+//   constexpr in C++20
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 #include "../cases.h"
 
 template 
+TEST_CONSTEXPR bool
+constexpr_test(const std::complex &z, std::complex x)
+{
+return proj(z) == x;
+}
+
+
+template 
 void
 test(const std::complex& z, std::complex x)
 {
@@ -29,10 +40,24 @@
 void
 test()
 {
-test(std::complex(1, 2), std::complex(1, 2));
-test(std::complex(-1, 2), std::complex(-1, 2));
-test(std::complex(1, -2), std::complex(1, -2));
-test(std::complex(-1, -2), std::complex(-1, -2));
+typedef std::complex C;
+
+TEST_CONSTEXPR C v12  ( 1,  2);
+TEST_CONSTEXPR C v1_2 ( 1, -2);
+TEST_CONSTEXPR C v_12 (-1,  2);
+TEST_CONSTEXPR C v_1_2(-1, -2);
+
+test(v12,   v12);
+test(v_12,  v_12);
+test(v1_2,  v1_2);
+test(v_1_2, v_1_2);
+
+#if TEST_STD_VER > 17
+static_assert(constexpr_test(v12,   v12), "");
+static_assert(constexpr_test(v_12,  v_12), "");
+static_assert(constexpr_test(v1_2,  v1_2), "");
+static_assert(constexpr_test(v_1_2, v_1_2), "");
+#endif
 }
 
 void test_edges()
Index: test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
===
--- test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
+++ test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
@@ -12,18 +12,31 @@
 // template
 //   T
 //   norm(const complex& x);
+//   constexpr in C++20
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 #include "../cases.h"
 
 template 
+TEST_CO

[PATCH] D40605: Better trade-off for excess characters vs. staying within the column limits.

2017-11-30 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 124940.
klimek added a comment.

Fix incorrect return value leading to unnecessary computation.


Repository:
  rC Clang

https://reviews.llvm.org/D40605

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9934,8 +9934,8 @@
   Style.PenaltyExcessCharacter = 90;
   verifyFormat("int a; // the comment", Style);
   EXPECT_EQ("int a; // the comment\n"
-"   // aa",
-format("int a; // the comment aa", Style));
+"   // aaa",
+format("int a; // the comment aaa", Style));
   EXPECT_EQ("int a; /* first line\n"
 "* second line\n"
 "* third line\n"
@@ -9963,14 +9963,14 @@
Style));
 
   EXPECT_EQ("// foo bar baz bazfoo\n"
-"// foo bar\n",
+"// foo bar foo bar\n",
 format("// foo bar baz bazfoo\n"
-   "// foobar\n",
+   "// foo bar foo   bar\n",
Style));
   EXPECT_EQ("// foo bar baz bazfoo\n"
-"// foo bar\n",
+"// foo bar foo bar\n",
 format("// foo bar baz  bazfoo\n"
-   "// foobar\n",
+   "// foobar foo bar\n",
Style));
 
   // FIXME: Optimally, we'd keep bazfoo on the first line and reflow bar to the
@@ -9996,6 +9996,15 @@
"// foo bar baz  bazfoo bar\n"
"// foo   bar\n",
Style));
+
+  // Make sure we do not keep protruding characters if strict mode reflow is
+  // cheaper than keeping protruding characters.
+  Style.ColumnLimit = 21;
+  EXPECT_EQ("// foo foo foo foo\n"
+"// foo foo foo foo\n"
+"// foo foo foo foo\n",
+format("// foo foo foo foo foo foo foo foo foo foo foo foo\n",
+   Style));
 }
 
 #define EXPECT_ALL_STYLES_EQUAL(Styles)\
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -123,14 +123,25 @@
   /// \brief If the current token sticks out over the end of the line, break
   /// it if possible.
   ///
-  /// \returns An extra penalty if a token was broken, otherwise 0.
+  /// \returns A pair (penalty, exceeded), where penalty is the extra penalty
+  /// when tokens are broken or lines exceed the column limit, and exceeded
+  /// indicates whether the algorithm purposefully left lines exceeding the
+  /// column limit.
   ///
   /// The returned penalty will cover the cost of the additional line breaks
   /// and column limit violation in all lines except for the last one. The
   /// penalty for the column limit violation in the last line (and in single
   /// line tokens) is handled in \c addNextStateToQueue.
-  unsigned breakProtrudingToken(const FormatToken &Current, LineState &State,
-bool AllowBreak, bool DryRun);
+  ///
+  /// \p Strict indicates whether reflowing is allowed to leave characters
+  /// protruding the column limit; if true, lines will be split strictly within
+  /// the column limit where possible; if false, words are allowed to protrude
+  /// over the column limit as long as the penalty is less than the penalty
+  /// of a break.
+  std::pair breakProtrudingToken(const FormatToken &Current,
+ LineState &State,
+ bool AllowBreak, bool DryRun,
+ bool Strict);
 
   /// \brief Returns the \c BreakableToken starting at \p Current, or nullptr
   /// if the current token cannot be broken.
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1390,7 +1390,36 @@
 Penalty = addMultilineToken(Current, State);
   } else if (State.Line->Type != LT_ImportStatement) {
 // We generally don't break import statements.
-Penalty = breakProtrudingToken(Current, State, AllowBreak, DryRun);
+LineState OriginalState = State;
+
+// Whether we force the reflowing algorithm to stay strictly within the
+// column limit.
+bool Strict = false;
+// Whether the first non-strict attempt at reflowing did intentionally
+// exceed the column limit.
+bool Exceeded = false;
+std::tie(Penalty, Exceeded) = breakProtrudingToken(
+Current, State, AllowBreak, /*DryRun=*/true, Strict);
+if (Exceeded) {
+  // If non-strict reflowing exceeds t

[PATCH] D40563: [SemaCodeComplete] Allow passing out scope specifiers in qualified-id completions via completion context.

2017-11-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D40563#939964, @arphaman wrote:

> If nothing uses `getCXXScopeSpecifier` right now we can't really test it with 
> a clang or c-index-test regression test. A completion unit test could work 
> here. I don't think we actually have existing completion unit tests though, 
> so you would have to create one from scratch. But if `getCXXScopeSpecifier` 
> will be used in a follow up patch maybe it will be easier to commit this 
> without a test together with the followup patch?


I have another clangd patch that uses this, but this would still need to be a 
separate patch since they are in different repos...


https://reviews.llvm.org/D40563



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


[PATCH] D40654: [clangd] Set completion options per-request.

2017-11-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: klimek.

Previously, completion options were set per ClangdServer instance.
It will allow to change completion preferences during the lifetime
of a single ClangdServer instance.

Also rewrote ClangdCompletionTest.CompletionOptions to reuse single
ClangdServer instance, the test now runs 2x faster on my machine.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40654

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -333,7 +333,6 @@
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
-clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
@@ -398,7 +397,6 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
@@ -445,7 +443,6 @@
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
@@ -495,25 +492,29 @@
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*AsyncThreadsCount=*/0,
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
   FS.Files[FooCpp] = SourceContents;
   FS.ExpectedFile = FooCpp;
 
+  // Use default completion options.
+  clangd::CodeCompleteOptions CCOpts;
+
   // No need to sync reparses, because requests are processed on the calling
   // thread.
   FS.Tag = "123";
   Server.addDocument(FooCpp, SourceContents);
-  EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).get().Tag, FS.Tag);
+  EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}, CCOpts).get().Tag,
+FS.Tag);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag);
 
   FS.Tag = "321";
   Server.addDocument(FooCpp, SourceContents);
   EXPECT_EQ(DiagConsumer.lastVFSTag(), FS.Tag);
-  EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).get().Tag, FS.Tag);
+  EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}, CCOpts).get().Tag,
+FS.Tag);
 }
 
 // Only enable this test on Unix
@@ -531,7 +532,6 @@
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*AsyncThreadsCount=*/0,
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -582,7 +582,6 @@
   ClangdServer Server(CDB, DiagConsumer, FS,
   /*AsyncThreadsCount=*/0,
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -651,7 +650,6 @@
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
-  clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -677,17 +675,19 @@
   // other async operations).
   Server.addDocument(FooCpp, SourceContents);
 
+  // Use default completion options.
+  clangd::CodeCompleteOptions CCOpts;
   {
 auto CodeCompletionResults1 =
-Server.codeComplete(FooCpp, CompletePos, None).get().Value;
+Server.codeComplete(FooCpp, CompletePos, CCOpts, None).get().Value;
 EXPECT_TRUE(ContainsItem(CodeCompletionResults1, "aba"));
 EXPECT_FALSE(ContainsItem(CodeCompletionResults1, "cbc"));
   }
 
   {
 auto CodeCompletionResultsOverriden =
 Server
-.codeComplete(FooCpp, CompletePos,
+.codeComplete(FooCpp, CompletePos, CCOpts,
   StringRef(OverridenSourceContents))
 .get()
 .Value;
@@ -697,7 +697,7 @@
 
   {
 auto CodeCompletionResults2 =
-Server.codeComplete(Fo

[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-30 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 124945.
Nebiroth marked an inline comment as done.
Nebiroth added a comment.

  Simplified getHover() function
  Proper usage of ErrorOr to return errors
  Given range for Hover struct now only applies to the open file
  Fixed crash on MacroExpansion


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,56 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 611
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nint test = 5;\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};}\n//comments test\ntemplate\nT templateTest(T foo) {\nreturn foo;}\ntemplate\nclass classTemplateTest {\npublic: T test;};\nint main() {\nint a;\na;\nint b = ns1::test;\nns1::MyClass* Params;\nParams->anotherOperation();\nMACRO;\nint temp = 5;\ntemplateTest(temp);classTemplateTest test;}\n"}}}
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":12}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":1}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"int a"}],"range":{"end":{"character":5,"line":20},"start":{"character":0,"line":20
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":22,"character":15}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"int test = 5"}],"range":{"end":{"character":12,"line":2},"start":{"character":0,"line":2
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":23,"character":10}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"struct MyClass {"}],"range":{"end":{"character":16,"line":3},"start":{"character":0,"line":3
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":24,"character":13}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1::MyClass"},{"language":"C++","value":"void anotherOperation() {"}],"range":{"end":{"character":25,"line":5},"start":{"character":0,"line":5
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":25,"character":1}}}
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.

[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-30 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:47
+Features.push_back("+d");
+break;
+  }

Can you also add a case for pushing back +c here?


https://reviews.llvm.org/D39963



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


[PATCH] D40654: [clangd] Set completion options per-request.

2017-11-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40654



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


[PATCH] D40594: [InstCombine] miscompile of __builtin_fmod

2017-11-30 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Added a blurb to the LangRef with https://reviews.llvm.org/rL319437, so I think 
we can abandon this patch.


https://reviews.llvm.org/D40594



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


r319446 - Fix __has_unique_object_representations implementation

2017-11-30 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Nov 30 08:37:02 2017
New Revision: 319446

URL: http://llvm.org/viewvc/llvm-project?rev=319446&view=rev
Log:
Fix __has_unique_object_representations implementation

As rsmith pointed out, the original implementation of this intrinsic
missed a number of important situations.  This patch fixe a bunch of
shortcomings and implementation details to make it work correctly.

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

Added:
cfe/trunk/test/SemaCXX/has_unique_object_reps_member_ptr.cpp   (with props)
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/CXXABI.h
cfe/trunk/lib/AST/ItaniumCXXABI.cpp
cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=319446&r1=319445&r2=319446&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Nov 30 08:37:02 2017
@@ -2149,6 +2149,10 @@ public:
   void CollectInheritedProtocols(const Decl *CDecl,
   llvm::SmallPtrSet &Protocols);
 
+  /// \brief Return true if the specified type has unique object 
representations
+  /// according to (C++17 [meta.unary.prop]p9)
+  bool hasUniqueObjectRepresentations(QualType Ty) const;
+
   
//======//
   //Type Operators
   
//======//

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=319446&r1=319445&r2=319446&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Nov 30 08:37:02 2017
@@ -808,10 +808,6 @@ public:
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext &Context) const;
 
-  /// Return true if this has unique object representations according to (C++17
-  /// [meta.unary.prop]p9)
-  bool hasUniqueObjectRepresentations(const ASTContext &Context) const;
-
   // Don't promise in the API that anything besides 'const' can be
   // easily added.
 
@@ -1164,9 +1160,6 @@ public:
   QualType getAtomicUnqualifiedType() const;
 
 private:
-  bool unionHasUniqueObjectRepresentations(const ASTContext& Context) const;
-  bool structHasUniqueObjectRepresentations(const ASTContext& Context) const;
-
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
   // caller.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=319446&r1=319445&r2=319446&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Nov 30 08:37:02 2017
@@ -1856,7 +1856,9 @@ TypeInfo ASTContext::getTypeInfoImpl(con
 break;
   case Type::MemberPointer: {
 const MemberPointerType *MPT = cast(T);
-std::tie(Width, Align) = ABI->getMemberPointerWidthAndAlign(MPT);
+CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
+Width = MPI.Width;
+Align = MPI.Align;
 break;
   }
   case Type::Complex: {
@@ -2138,6 +2140,168 @@ void ASTContext::CollectInheritedProtoco
   }
 }
 
+static bool unionHasUniqueObjectRepresentations(const ASTContext &Context,
+const RecordDecl *RD) {
+  assert(RD->isUnion() && "Must be union type");
+  CharUnits UnionSize = Context.getTypeSizeInChars(RD->getTypeForDecl());
+
+  for (const auto *Field : RD->fields()) {
+if (!Context.hasUniqueObjectRepresentations(Field->getType()))
+  return false;
+CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
+if (FieldSize != UnionSize)
+  return false;
+  }
+  return true;
+}
+
+bool isStructEmpty(QualType Ty) {
+  const RecordDecl *RD = Ty->castAs()->getDecl();
+
+  if (!RD->field_empty())
+return false;
+
+  if (const auto *ClassDecl = dyn_cast(RD))
+return ClassDecl->isEmpty();
+
+  return true;
+}
+
+static llvm::Optional
+structHasUniqueObjectRepresentations(const ASTContext &Context,
+ const RecordDecl *RD) {
+  assert(!RD->isUnion() && "Must be struct/class type");
+  const auto &Layout = Context.getASTRecordLayout(RD);
+
+  int64_t CurOffsetInBits = 0;
+  if (const auto *ClassDecl = dyn_cast(RD)) {
+if (Cla

[PATCH] D39347: Fix __has_unique_object_representations based on rsmith's input

2017-11-30 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319446: Fix __has_unique_object_representations 
implementation (authored by erichkeane).

Repository:
  rC Clang

https://reviews.llvm.org/D39347

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/CXXABI.h
  lib/AST/ItaniumCXXABI.cpp
  lib/AST/MicrosoftCXXABI.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/has_unique_object_reps_member_ptr.cpp
  test/SemaCXX/type-traits.cpp

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1856,7 +1856,9 @@
 break;
   case Type::MemberPointer: {
 const MemberPointerType *MPT = cast(T);
-std::tie(Width, Align) = ABI->getMemberPointerWidthAndAlign(MPT);
+CXXABI::MemberPointerInfo MPI = ABI->getMemberPointerInfo(MPT);
+Width = MPI.Width;
+Align = MPI.Align;
 break;
   }
   case Type::Complex: {
@@ -2138,6 +2140,168 @@
   }
 }
 
+static bool unionHasUniqueObjectRepresentations(const ASTContext &Context,
+const RecordDecl *RD) {
+  assert(RD->isUnion() && "Must be union type");
+  CharUnits UnionSize = Context.getTypeSizeInChars(RD->getTypeForDecl());
+
+  for (const auto *Field : RD->fields()) {
+if (!Context.hasUniqueObjectRepresentations(Field->getType()))
+  return false;
+CharUnits FieldSize = Context.getTypeSizeInChars(Field->getType());
+if (FieldSize != UnionSize)
+  return false;
+  }
+  return true;
+}
+
+bool isStructEmpty(QualType Ty) {
+  const RecordDecl *RD = Ty->castAs()->getDecl();
+
+  if (!RD->field_empty())
+return false;
+
+  if (const auto *ClassDecl = dyn_cast(RD))
+return ClassDecl->isEmpty();
+
+  return true;
+}
+
+static llvm::Optional
+structHasUniqueObjectRepresentations(const ASTContext &Context,
+ const RecordDecl *RD) {
+  assert(!RD->isUnion() && "Must be struct/class type");
+  const auto &Layout = Context.getASTRecordLayout(RD);
+
+  int64_t CurOffsetInBits = 0;
+  if (const auto *ClassDecl = dyn_cast(RD)) {
+if (ClassDecl->isDynamicClass())
+  return llvm::None;
+
+SmallVector, 4> Bases;
+for (const auto Base : ClassDecl->bases()) {
+  // Empty types can be inherited from, and non-empty types can potentially
+  // have tail padding, so just make sure there isn't an error.
+  if (!isStructEmpty(Base.getType())) {
+llvm::Optional Size = structHasUniqueObjectRepresentations(
+Context, Base.getType()->getAs()->getDecl());
+if (!Size)
+  return llvm::None;
+Bases.emplace_back(Base.getType(), Size.getValue());
+  }
+}
+
+std::sort(
+Bases.begin(), Bases.end(), [&](const std::pair &L,
+const std::pair &R) {
+  return Layout.getBaseClassOffset(L.first->getAsCXXRecordDecl()) <
+ Layout.getBaseClassOffset(R.first->getAsCXXRecordDecl());
+});
+
+for (const auto Base : Bases) {
+  int64_t BaseOffset = Context.toBits(
+  Layout.getBaseClassOffset(Base.first->getAsCXXRecordDecl()));
+  int64_t BaseSize = Base.second;
+  if (BaseOffset != CurOffsetInBits)
+return llvm::None;
+  CurOffsetInBits = BaseOffset + BaseSize;
+}
+  }
+
+  for (const auto *Field : RD->fields()) {
+if (!Field->getType()->isReferenceType() &&
+!Context.hasUniqueObjectRepresentations(Field->getType()))
+  return llvm::None;
+
+int64_t FieldSizeInBits =
+Context.toBits(Context.getTypeSizeInChars(Field->getType()));
+if (Field->isBitField()) {
+  int64_t BitfieldSize = Field->getBitWidthValue(Context);
+
+  if (BitfieldSize > FieldSizeInBits)
+return llvm::None;
+  FieldSizeInBits = BitfieldSize;
+}
+
+int64_t FieldOffsetInBits = Context.getFieldOffset(Field);
+
+if (FieldOffsetInBits != CurOffsetInBits)
+  return llvm::None;
+
+CurOffsetInBits = FieldSizeInBits + FieldOffsetInBits;
+  }
+
+  return CurOffsetInBits;
+}
+
+bool ASTContext::hasUniqueObjectRepresentations(QualType Ty) const {
+  // C++17 [meta.unary.prop]:
+  //   The predicate condition for a template specialization
+  //   has_unique_object_representations shall be
+  //   satisfied if and only if:
+  // (9.1) - T is trivially copyable, and
+  // (9.2) - any two objects of type T with the same value have the same
+  // object representation, where two objects
+  //   of array or non-union class type are considered to have the same value
+  //   if their respective sequences of
+  //   direct subobjects have the same values, and two objects of union type
+  //   are considered to have the same
+  //   value if they have the same active member and the corresponding members
+  //   have the same value.
+  //   The set of scalar types for wh

[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-11-30 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 124949.
juliehockett added a comment.

Updated warning wording to more accurately reflect guidelines


https://reviews.llvm.org/D40580

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-multiple-inheritance.cpp

Index: test/clang-tidy/fuchsia-multiple-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+
+class Base_A {
+public:
+  virtual int foo() { return 0; }
+};
+
+class Base_B {
+public:
+  virtual int bar() { return 0; }
+};
+
+class Base_A_child : public Base_A {
+public:
+  virtual int baz() { return 0; }
+};
+
+class Interface_A {
+public:
+  virtual int foo() = 0;
+};
+
+class Interface_B {
+public:
+  virtual int bar() = 0;
+};
+
+class Interface_C {
+public:
+  virtual int blat() = 0;
+};
+
+class Interface_A_with_member {
+public:
+  virtual int foo() = 0;
+  int val = 0;
+};
+
+class Interface_with_A_Parent : public Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+// Inherits from multiple concrete classes.
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
+class Bad_Child1 : public Base_A, Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+class Bad_Child2 : public Base_A, Interface_A_with_member {
+  virtual int foo() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// Easy cases of single inheritance
+class Simple_Child1 : public Base_A {};
+class Simple_Child2 : public Interface_A {
+  virtual int foo() override { return 0; }
+};
+
+// Valid uses of multiple inheritance
+class Good_Child1 : public Interface_A, Interface_B {
+  virtual int foo() override { return 0; }
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child2 : public Base_A, Interface_B {
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
+  virtual int bar() override { return 0; }
+  virtual int blat() override { return 0; }
+};
+
+int main(void) {
+  Bad_Child1 a;
+  Bad_Child2 b;
+  Bad_Child3 c;
+  Simple_Child1 d;
+  Simple_Child2 e;
+  Good_Child1 f;
+  Good_Child2 g;
+  Good_Child3 h;
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
fuchsia-default-arguments
+   fuchsia-multiple-inheritance
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
@@ -0,0 +1,46 @@
+.. title:: clang-tidy - fuchsia-multiple-inheritance
+
+fuchsia-multiple-inheritance
+
+
+Warns if a class inherits from multiple classes that are not pure virtual.
+
+For example, declaring a class that inherits from multiple concrete classes is
+disallowed:
+
+.. code-block:: c++
+
+  class Base_A {
+  public:
+virtual int foo() { return 0; }
+  };
+
+  class Base_B {
+  public:
+virtual int bar() { return 0; }
+  };
+
+  // Warning
+  class Bad_Child1 : public Base_A, Base_B {};
+
+A class that inherits from a pure virtual is allowed:
+
+.. code-block:: c++
+
+  class Interface_A {
+  public:
+virtual int foo() = 0;
+  };
+
+  class Interface_B {
+  public:
+virtual int bar() = 0;
+  };
+
+  // No warning
+  class Good_Child1 : public Interface_A, Interface_B {
+virtual int foo() override { return 0; }
+virtual int bar() override { return 0; }
+  };
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -135,6 +135,11 @@
 
   Warns if a function or method is declared or called with default ar

[PATCH] D38425: [clangd] Document highlights for clangd

2017-11-30 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 124951.
Nebiroth marked 6 inline comments as done.
Nebiroth added a comment.

  Minor code cleanup
  getDeclarationLocation now returns llvm::Optional
  operator< for DocumentHighlight struct now properly compares the kind field


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -20,6 +20,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
+# CHECK-NEXT:  "documentHighlightProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "}",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 479
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nint test1 = bonjour;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();\n}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Verify local variable 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":17}}}
+# Verify struct highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":21,"character":10}}}
+# Verify method highlight
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":14,"line":2},"start":{"character":7,"line":2}}},{"kind":1,"range":{"end":{"character":22,"line":6},"start":{"character":15,"line":6}}},{"kind":1,"range":{"end":{"character":12,"line":21},"start":{"character":5,"line":21}}}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"character":14}}}
+# Verify Read-access of a symbol (kind = 2) 
+# CHECK: {"id":1,"jsonrpc":"2.0","result":[{"kind":1,"range":{"end":{"character":11,"line":16},"start":{"character":4,"line":16}}},{"kind":3,"range":{"end":{"character":7,"line":17},"start":{"character":0,"line":17}}},{"kind":2,"range":{"end":{"character":19,"line":18},"start":{"character":12,"line":18}}}]}
+
+Content-Length: 48
+
+{"jsonrpc":"2.0","id":1,"method":"shutdown"}
+
+Content-Length: 33
+
+{"jsonr

[PATCH] D40605: Better trade-off for excess characters vs. staying within the column limits.

2017-11-30 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/Format/FormatTest.cpp:10007
+format("// foo foo foo foo foo foo foo foo foo foo foo foo\n",
+   Style));
 }

Could you also add a test with line comments surrounded by stuff, like in:
```
int f() {
  int a = /* long block comment */ 42;
}


Repository:
  rC Clang

https://reviews.llvm.org/D40605



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


[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

In https://reviews.llvm.org/D36431#940169, @nemanjai wrote:

> This has been sitting in approved state for more than 2 months. As far as I 
> can tell, it wasn't committed. Do you plan to commit this soon or are you 
> abandoning it for some reason?


My apologies. I have gotten distracted by other things and will get this 
submitted shortly.


https://reviews.llvm.org/D36431



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


[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-11-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/fuchsia/MultipleInheritanceCheck.cpp:35-36
+  StringRef Name = Node->getIdentifier()->getName();
+  if (InterfaceMap.count(Name)) {
+isInterface = InterfaceMap.lookup(Name);
+return true;

One lookup is enough here. Use `StringMap::find()` instead of count + lookup.


https://reviews.llvm.org/D40580



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


[PATCH] D40448: Add a printing policy for AST dumping

2017-11-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D40448



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


r319450 - [OPENMP] Fix possible assert for target regions with incorrect inner

2017-11-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov 30 10:01:54 2017
New Revision: 319450

URL: http://llvm.org/viewvc/llvm-project?rev=319450&view=rev
Log:
[OPENMP] Fix possible assert for target regions with incorrect inner
teams region.

If the inner teams region is not correct, it may cause an assertion when
processing outer target region. Patch fixes this problem.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Nov 30 10:01:54 2017
@@ -2674,7 +2674,6 @@ static bool checkNestingOfRegions(Sema &
   NestingProhibited = ParentRegion != OMPD_target;
   OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
-  Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
 }
 if (!NestingProhibited &&
 !isOpenMPTargetExecutionDirective(CurrentRegion) &&
@@ -6569,6 +6568,8 @@ StmtResult Sema::ActOnOpenMPTeamsDirecti
 
   getCurFunction()->setHasBranchProtectedScope();
 
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
 }
 
@@ -7071,6 +7072,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
  "omp teams distribute loop exprs were not built");
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7119,6 +7123,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
 return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeSimdDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7167,6 +7174,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
 return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeParallelForSimdDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
 }
@@ -7213,6 +7223,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistrib
  "omp for loop exprs were not built");
 
   getCurFunction()->setHasBranchProtectedScope();
+
+  DSAStack->setParentTeamsRegionLoc(StartLoc);
+
   return OMPTeamsDistributeParallelForDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
   DSAStack->isCancelRegion());

Modified: cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp Thu Nov 30 
10:01:54 2017
@@ -689,6 +689,9 @@ void test_loop_eh() {
   void g() { throw 0; }
 };
   }
+  #pragma omp target
+  #pragma omp teams distribute
+  f; // expected-error {{use of undeclared identifier 'f'}}
 }
 
 void test_loop_firstprivate_lastprivate() {

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp?rev=319450&r1=319449&r2=319450&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp Thu Nov 30 
10:01:54 2017
@@ -9,6 +9,9 @@ static int pvt;
 #pragma omp teams distribute parallel for // expected-error {{unexpected 
OpenMP directive '#pragma omp teams distribute parallel for'}}
 
 int main(int argc, char **argv) {
+  #pragma omp target
+  #pragma omp teams distribute parallel for
+  f; // expected-error {{use of undeclared identifier 'f'}}
 #pragma omp target
 #pragma omp teams distribute parallel for { // expected-warning {{extra tokens 
at the end of '#pragma omp teams distribute parallel for' are ignored}}
   for (int i = 0; i < argc; ++i)

Modified: cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp?rev=319450&r1=319449&r2

[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
Herald added a subscriber: cfe-commits.

The MSVC driver and clang do not link against the C++ runtime
explicitly.  Instead, they rely on the auto-linking via the pragma
(through `use_ansi.h`) to link against the correct version of the C++
runtime.  Attempt to do something similar here so that linking real C++
code on Windows does not require the user to explicitly specify
`c++.lib` when using libc++ as a C++ runtime on windows.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma(lib, "c++d.lib")
+#   else
+# pragma(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma(lib, "c++d.lib")
+#   else
+# pragma(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2017-11-30 Thread Dan Olson via Phabricator via cfe-commits
dolson added a comment.

Hello,

In the process of upgrading from clang 3.6.1 to a newer version, I ran into 
this new error and thus imported the new intrinsics from intrin.h for rep movsb 
and friends.  I see several discussions in this thread about how having the 
registers solely in the inputs list is not sufficient for something like "rep 
movsb" because the modified registers will not be clobbered, however none of 
these suggested changes made it into the eventual intrin.h.

I found that using the versions of `__movsb` and `__stosb` that are at the head 
revision intrin.h produced bad code generation vs the versions with the 
clobbers.  Note this is on PS4 under the older clang 3.6.1, but I don't see 
anything in this CL that would update the clobber behavior for newer versions 
of clang.

Shouldn't the intrinsics be updated to use input/output registers or some other 
method of clobbering?


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 124968.
sammccall marked 5 inline comments as done.
sammccall added a comment.

- added more VSCode tests, and made test assert matched characters. This 
uncovered algorithm problems
- cache now includes "did previous character match" in the key (scoring depends 
on this, so we gave incorrect results)
- added a penalty for non-consecutive matches
- first character matching inside a segment downgraded from a ban to a penalty 
This allows [stream] to match "istream"
- don't award case bonuses if the query is all lowercase. This helps matches 
like [ccm] -> [c]ode[C]ompletec[m] compete with [c]odeComplete[cm]


https://reviews.llvm.org/D40060

Files:
  clangd/CMakeLists.txt
  clangd/FuzzyMatch.cpp
  clangd/FuzzyMatch.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FuzzyMatchTests.cpp

Index: unittests/clangd/FuzzyMatchTests.cpp
===
--- /dev/null
+++ unittests/clangd/FuzzyMatchTests.cpp
@@ -0,0 +1,252 @@
+//===-- FuzzyMatchTests.cpp - String fuzzy matcher tests *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using namespace llvm;
+using testing::Not;
+
+struct ExpectedMatch {
+  ExpectedMatch(StringRef Annotated) : Word(Annotated), Annotated(Annotated) {
+for (char C : "[]")
+  Word.erase(std::remove(Word.begin(), Word.end(), C), Word.end());
+  }
+  std::string Word;
+  StringRef Annotated;
+};
+raw_ostream &operator<<(raw_ostream &OS, const ExpectedMatch &M) {
+  return OS << "'" << M.Word << "' as " << M.Annotated;
+}
+
+struct MatchesMatcher : public testing::MatcherInterface {
+  ExpectedMatch Candidate;
+  MatchesMatcher(ExpectedMatch Candidate) : Candidate(std::move(Candidate)) {}
+
+  void DescribeTo(::std::ostream *OS) const override {
+raw_os_ostream(*OS) << "Matches " << Candidate;
+  }
+
+  bool MatchAndExplain(StringRef Pattern,
+   testing::MatchResultListener *L) const override {
+std::unique_ptr OS(
+L->stream() ? (raw_ostream *)(new raw_os_ostream(*L->stream()))
+: new raw_null_ostream());
+FuzzyMatcher Matcher(Pattern);
+auto Result = Matcher.match(Candidate.Word);
+auto AnnotatedMatch = Matcher.dumpLast(*OS << "\n");
+return Result && AnnotatedMatch == Candidate.Annotated;
+  }
+};
+
+// Accepts patterns that match a given word.
+// Dumps the debug tables on match failure.
+testing::Matcher matches(StringRef M) {
+  return testing::MakeMatcher(new MatchesMatcher(M));
+}
+
+TEST(FuzzyMatch, Matches) {
+  EXPECT_THAT("u_p", matches("[u]nique[_p]tr"));
+  EXPECT_THAT("up", matches("[u]nique_[p]tr"));
+  EXPECT_THAT("uq", matches("[u]ni[q]ue_ptr"));
+  EXPECT_THAT("qp", Not(matches("unique_ptr")));
+  EXPECT_THAT("log", Not(matches("SVGFEMorphologyElement")));
+
+  EXPECT_THAT("tit", matches("win.[tit]"));
+  EXPECT_THAT("title", matches("win.[title]"));
+  EXPECT_THAT("WordCla", matches("[Word]Character[Cla]ssifier"));
+  EXPECT_THAT("WordCCla", matches("[WordC]haracter[Cla]ssifier"));
+
+  EXPECT_THAT("dete", Not(matches("editor.quickSuggestionsDelay")));
+
+  EXPECT_THAT("highlight", matches("editorHover[Highlight]"));
+  EXPECT_THAT("hhighlight", matches("editor[H]over[Highlight]"));
+  EXPECT_THAT("dhhighlight", Not(matches("editorHoverHighlight")));
+
+  EXPECT_THAT("-moz", matches("[-moz]-foo"));
+  EXPECT_THAT("moz", matches("-[moz]-foo"));
+  EXPECT_THAT("moza", matches("-[moz]-[a]nimation"));
+
+  EXPECT_THAT("ab", matches("[ab]A"));
+  EXPECT_THAT("ccm", matches("[c]a[cm]elCase"));
+  EXPECT_THAT("bti", Not(matches("the_black_knight")));
+  EXPECT_THAT("ccm", Not(matches("camelCase")));
+  EXPECT_THAT("cmcm", Not(matches("camelCase")));
+  EXPECT_THAT("BK", matches("the_[b]lack_[k]night"));
+  EXPECT_THAT("KeyboardLayout=", Not(matches("KeyboardLayout")));
+  EXPECT_THAT("LLL", matches("SVisual[L]ogger[L]ogs[L]ist"));
+  EXPECT_THAT("", Not(matches("SVilLoLosLi")));
+  EXPECT_THAT("", Not(matches("SVisualLoggerLogsList")));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]"));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]or"));
+  EXPECT_THAT("TEdit", matches("[Te]xte[dit]"));
+  EXPECT_THAT("TEdit", matches("[t]ext_[edit]"));
+  EXPECT_THAT("TEditDit", matches("[T]ext[Edit]or[D]ecorat[i]on[T]ype"));
+  EXPECT_THAT("TEdit", matches("[T]ext[Edit]orDecorationType"));
+  EXPECT_THAT("Tedit", matches("[T]ext[Edit]"));
+  EXPECT_THAT("ba", Not(matches("?AB?")));
+  EXPECT_THAT("bkn", matches("the_[b]lack_[kn]ight"));
+  EXPECT_THAT("bt", matches("the_[b]lack_knigh[t]"));
+  EXPECT_THAT("ccm"

[PATCH] D40060: [clangd] Fuzzy match scorer

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks @ilya-biryukov, @inspirer, @klimek for the helpful comments!

I've addressed hopefully the most important and added more rigorous testing.
Sorry for the large delta, the most invasive change was of course adding the 
extra dimension to the scoring table. (Which fixed a bunch of problems)




Comment at: clangd/FuzzyMatch.cpp:118
+0x00, 0x00, 0x00, 0x00, // Control characters
+0xff, 0xff, 0xff, 0xff, // Punctuation
+0x55, 0x55, 0xf5, 0xff, // Numbers->Lower, more Punctuation.

ilya-biryukov wrote:
> I'm not sure if we care, but maybe we should treat `+`, `-` and other symbols 
> that could be in operator names (e.g., `operator +`) differently for C++.
> Could also make sense for other languages with overloaded operators.
You might be right, but in the absence of concrete problems I think treating 
them as punctuation is actually the most conservative thing to do.

E.g. matching [op=] against "operator=" gets big penalties if we treat '=' as 
Lower, and treating it as Upper seems likely to have other weird effects... 
Punctuation/separators are treated pretty neutrally.



Comment at: clangd/FuzzyMatch.cpp:245
+  if (!P && WordRole[W] == Tail)
+return AwfulScore;
+  ScoreT S = 0;

ilya-biryukov wrote:
> Does it mean I will get no matches in the following situation?
> 
> `Items = [printf, scanf]`
> `Pattern = f`
> 
> It may be a bit confusing, since I do have a match, even though is terrible 
> and it's ok to put those items very low in the list.
> A more real example is:
> `Items = [fprintf, fscanf]`
> `Pattern = print`
> 
> Would `fprintf` match in that case? I think it should.
> 
> Another important one:
> `Items = [istream, ostream]`
> `Pattern = stream`
Done. VSCode will filter these out, but I agree these are important and don't 
seem to cause problems.



Comment at: clangd/FuzzyMatch.cpp:254
+  // Penalty: matching inside a segment (and previous char wasn't matched).
+  if (WordRole[W] == Tail && P && !Matched[P - 1][W - 1])
+S -= 3;

inspirer wrote:
> You need a third boolean dimension in your DP table for this condition to 
> work - "matches".
> 
> Consider matching "Abde" against "AbdDe". The result should be [Ab]d[De] and 
> not [Abd]D[e]. While evaluating Abd against AbdD, you will have to choose 
> between two ways to represent the match and no matter what you choose, 
> scoring in this line will not know whether your previous char matched, since 
> you merged two branches and kept only one of them.
> 
> This scoring works OK-ish since you check "if (Diag >= Left)" above and so 
> you Matched table is full of trues, but you matches will gravitate towards 
> the ends of the candidate string if you decide to show them in the UI.
Thank you for this! Fixed. The naming around Scores/ScoreInfo is a bit clumsy, 
happy to take suggestions :-(

I've also made all our tests assert the exact characters matched. We don't have 
an API or need this feature, but it makes the tests detect a lot more 
misbehavior that's hard to capture otherwise.



Comment at: clangd/FuzzyMatch.h:53
+
+  int PatN, WordN;   // Length of pattern and word.
+  char Pat[MaxPat], Word[MaxWord];   // Raw pattern and word data.

ilya-biryukov wrote:
> Maybe we could split the data we store into two sections:
> 1. Pattern-specific data. Initialized on construction, never changed later.
> 2. Per-match data. Initialized per `match()` call.
> 
> Otherwise it is somewhat hard to certify whether everything is being 
> initialized properly.
This hides the parallels between the Pattern and Word data, I'm not sure I like 
it better overall.

I've added a comment describing this split, reordered some variables, and 
renamed IsSubstring to WordContainsPattern, which I think clarifies this a bit. 
WDYT?


https://reviews.llvm.org/D40060



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


r319458 - [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Kelvin Li via cfe-commits
Author: kli
Date: Thu Nov 30 10:52:06 2017
New Revision: 319458

URL: http://llvm.org/viewvc/llvm-project?rev=319458&view=rev
Log:
[OpenMP] Diagnose undeclared variables on declare target clause

Clang asserts on undeclared variables on the to or link clause in the declare
target directive. The patch is to properly diagnose the error.

// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)

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


Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=319458&r1=319457&r2=319458&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Nov 30 10:52:06 2017
@@ -1506,7 +1506,7 @@ public:
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }

Modified: cfe/trunk/test/OpenMP/declare_target_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_messages.cpp?rev=319458&r1=319457&r2=319458&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp Thu Nov 30 10:52:06 2017
@@ -13,6 +13,10 @@ void f();
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;


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


[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319458: [OpenMP] Diagnose undeclared variables on declare 
target clause (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D40588?vs=124811&id=124969#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40588

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/declare_target_messages.cpp


Index: cfe/trunk/test/OpenMP/declare_target_messages.cpp
===
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }


Index: cfe/trunk/test/OpenMP/declare_target_messages.cpp
===
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
 extern int b;
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40588: [OpenMP] Diagnose undeclared variables on declare target clause

2017-11-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319458: [OpenMP] Diagnose undeclared variables on declare 
target clause (authored by kli).

Repository:
  rC Clang

https://reviews.llvm.org/D40588

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_target_messages.cpp


Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, 
only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared 
identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared 
identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
 extern int b;


Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -1506,7 +1506,7 @@
   explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
   bool ValidateCandidate(const TypoCorrection &Candidate) override {
 NamedDecl *ND = Candidate.getCorrectionDecl();
-if (isa(ND) || isa(ND)) {
+if (ND && (isa(ND) || isa(ND))) {
   return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
SemaRef.getCurScope());
 }
Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -13,6 +13,10 @@
 
 #pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
 
+#pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
+
+#pragma omp declare target link(foo2) // expected-error {{use of undeclared identifier 'foo2'}}
+
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
 extern int b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 124971.
Wizard added a comment.

change file name cases


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40528

Files:
  clang-tidy/objc/AvoidNSEErrorInitCheck.cpp
  clang-tidy/objc/AvoidNSEErrorInitCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  test/clang-tidy/objc-avoid-nserror-init.m

Index: test/clang-tidy/objc-avoid-nserror-init.m
===
--- /dev/null
+++ test/clang-tidy/objc-avoid-nserror-init.m
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s objc-avoid-nserror-init %t
+@interface NSError
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@implementation foo
+- (void)bar {
+NSError *error = [[NSError alloc] init];
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to create a new NSError [objc-avoid-nserror-init]
+}
+@end
Index: docs/clang-tidy/checks/objc-avoid-nserror-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-avoid-nserror-init.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-avoid-nserror-init
+
+objc-avoid-nserror-init
+===
+
+This check will find out improper initialization of NSError objects.
+
+According to Apple developer document, we should always use factory method 
+``errorWithDomain:code:userInfo:`` to create new NSError objects instead
+of ``[NSError alloc] init]``. Otherwise it will lead to a warning message
+during runtime.
+
+The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,6 +173,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -158,6 +163,11 @@
   Finds uses of bitwise operations on signed integer types, which may lead to 
   undefined or implementation defined behaviour.
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New `objc-avoid-spinlock
   `_ check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tidy/objc/CMakeLists.txt
===
--- clang-tidy/objc/CMakeLists.txt
+++ clang-tidy/objc/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
+  AvoidNSErrorInitCheck.cpp
   AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp
   ObjCTidyModule.cpp
Index: clang-tidy/objc/AvoidNSEErrorInitCheck.h
===
--- /dev/null
+++ clang-tidy/objc/AvoidNSEErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINI

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319459: add new check to find NSError init invocation 
(authored by Wizard).

Changed prior to commit:
  https://reviews.llvm.org/D40528?vs=124972&id=124974#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40528

Files:
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
  clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m

Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds usages of [NSSError init]. It is not the proper way of creating
+/// NSError. errorWithDomain:code:userInfo: should be used instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-nserror-init.html
+class AvoidNSErrorInitCheck : public ClangTidyCheck {
+ public:
+  AvoidNSErrorInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
@@ -0,0 +1,37 @@
+//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidNSErrorInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcMessageExpr(hasSelector("init"),
+ hasReceiverType(asString("NSError *")))
+ .bind("nserrorInit"),
+ this);
+}
+
+void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedExpr =
+  Result.Nodes.getNodeAs("nserrorInit");
+  diag(MatchedExpr->getLocStart(),
+   "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to "
+   "create a new NSError");
+}
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/objc/C

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 124972.
Wizard added a comment.

restore file names


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40528

Files:
  clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  clang-tidy/objc/AvoidNSErrorInitCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-nserror-init.rst
  test/clang-tidy/objc-avoid-nserror-init.m

Index: test/clang-tidy/objc-avoid-nserror-init.m
===
--- /dev/null
+++ test/clang-tidy/objc-avoid-nserror-init.m
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s objc-avoid-nserror-init %t
+@interface NSError
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@implementation foo
+- (void)bar {
+NSError *error = [[NSError alloc] init];
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to create a new NSError [objc-avoid-nserror-init]
+}
+@end
Index: docs/clang-tidy/checks/objc-avoid-nserror-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-avoid-nserror-init.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - objc-avoid-nserror-init
+
+objc-avoid-nserror-init
+===
+
+This check will find out improper initialization of NSError objects.
+
+According to Apple developer document, we should always use factory method 
+``errorWithDomain:code:userInfo:`` to create new NSError objects instead
+of ``[NSError alloc] init]``. Otherwise it will lead to a warning message
+during runtime.
+
+The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,6 +173,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -158,6 +163,11 @@
   Finds uses of bitwise operations on signed integer types, which may lead to 
   undefined or implementation defined behaviour.
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New `objc-avoid-spinlock
   `_ check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidNSErrorInitCheck.h"
 #include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
@@ -23,6 +24,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"objc-avoid-nserror-init");
 CheckFactories.registerCheck(
 "objc-avoid-spinlock");
 CheckFactories.registerCheck(
Index: clang-tidy/objc/CMakeLists.txt
===
--- clang-tidy/objc/CMakeLists.txt
+++ clang-tidy/objc/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
+  AvoidNSErrorInitCheck.cpp
   AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp
   ObjCTidyModule.cpp
Index: clang-tidy/objc/AvoidNSErrorInitCheck.h
===
--- /dev/null
+++ clang-tidy/objc/AvoidNSErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H

[PATCH] D40528: add new check to find NSError init invocation

2017-11-30 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319460: add new check to find NSError init invocation 
(authored by Wizard).

Changed prior to commit:
  https://reviews.llvm.org/D40528?vs=124972&id=124973#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40528

Files:
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst

Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidNSErrorInitCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds usages of [NSSError init]. It is not the proper way of creating
+/// NSError. errorWithDomain:code:userInfo: should be used instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-nserror-init.html
+class AvoidNSErrorInitCheck : public ClangTidyCheck {
+ public:
+  AvoidNSErrorInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOIDNSERRORINITCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
@@ -0,0 +1,37 @@
+//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "AvoidNSErrorInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(objcMessageExpr(hasSelector("init"),
+ hasReceiverType(asString("NSError *")))
+ .bind("nserrorInit"),
+ this);
+}
+
+void AvoidNSErrorInitCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedExpr =
+  Result.Nodes.getNodeAs("nserrorInit");
+  diag(MatchedExpr->getLocStart(),
+   "use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to "
+   "create a new NSError");
+}
+
+}  // namespace objc
+}  // namespace tidy
+}  // namespace clang
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-nserror-init
+  `_ check
+
+  Add new check to detect the use of [NSError init].
+
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
Index: clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNserrorInitCheck.cpp
@@ -1,37 +0,0 @@
-//===--- AvoidNSErrorInitCheck.cpp - clang-tidy===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===

[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 124976.
compnerd added a comment.

Fix pragma, ensure that we do not try to recursively link.


https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,15 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")
+#   endif
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
thing.



Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

I guess `_DLL` is appropriate here. Ideally though I think adding the pragma 
should be keyed on exactly the same conditional that determines whether we 
annotate with dllexport/dllimport, and right now that's only conditional on 
`_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

We never create a `c++d.lib`, as far as I can see. It's always either `c++.lib` 
for the import library or `libc++.lib` for the static library.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

smeenai wrote:
> This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
> thing.
I think if you're not using the MS ABI, you're probably using the GCC-style 
driver to compile and link, and that is what normally adds the C++ library to 
the link line.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

smeenai wrote:
> We never create a `c++d.lib`, as far as I can see. It's always either 
> `c++.lib` for the import library or `libc++.lib` for the static library.
Yeah, I'd leave that out until we actually commit cmake or install scripts that 
make this library.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

rnk wrote:
> smeenai wrote:
> > This feels more like a Windows (or perhaps COFF) thing than a Microsoft ABI 
> > thing.
> I think if you're not using the MS ABI, you're probably using the GCC-style 
> driver to compile and link, and that is what normally adds the C++ library to 
> the link line.
Yeah, that's fair.


https://reviews.llvm.org/D40660



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


[PATCH] D36555: Move x86-specific sources to x86-specific source lists.

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine closed this revision.
saugustine added a comment.

Committed as R319464.


https://reviews.llvm.org/D36555



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/__config:1266
+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)

smeenai wrote:
> rnk wrote:
> > smeenai wrote:
> > > This feels more like a Windows (or perhaps COFF) thing than a Microsoft 
> > > ABI thing.
> > I think if you're not using the MS ABI, you're probably using the GCC-style 
> > driver to compile and link, and that is what normally adds the C++ library 
> > to the link line.
> Yeah, that's fair.
Well, is it really a windows thing?  What about MinGW/cygwin?

The interesting thing here is that if you use the `itanium` environment, 
`-lc++` is added to the linker invocation (though it is the BFD linker rather 
than lld).  For the MSVC environment, which assumes a MS ABI style C++ library, 
we do not emit the `c++.lib`.  However, this would accomplish that.



Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

smeenai wrote:
> I guess `_DLL` is appropriate here. Ideally though I think adding the pragma 
> should be keyed on exactly the same conditional that determines whether we 
> annotate with dllexport/dllimport, and right now that's only conditional on 
> `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
Its more complicated.  This is for the *user* not the library itself.  When 
building the shared library we need to ensure that it is not added 
(`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, the 
`_DLL` tells you about the dynamic/static behavior.



Comment at: include/__config:1269
+# pragma comment(lib, "c++d.lib")
+#   else
+# pragma comment(lib, "c++.lib")

rnk wrote:
> smeenai wrote:
> > We never create a `c++d.lib`, as far as I can see. It's always either 
> > `c++.lib` for the import library or `libc++.lib` for the static library.
> Yeah, I'd leave that out until we actually commit cmake or install scripts 
> that make this library.
Okay, I can drop this bit of the diff.


https://reviews.llvm.org/D40660



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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 124983.
compnerd added a comment.

@rnk/@smeenai don't want future proofing


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660

Files:
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,11 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   pragma comment(lib, "c++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus



Index: include/__config
===
--- include/__config
+++ include/__config
@@ -1263,6 +1263,11 @@
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)

+#if defined(_LIBCPP_ABI_MICROSOFT)
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   pragma comment(lib, "c++.lib")
+# endif
+#endif // defined(_LIBCPP_ABI_MICROSOFT)

 #endif // __cplusplus

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


[PATCH] D40660: Enable auto-linking on Windows

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I'm fine with future proofing, but not if it doesn't actually work in the 
present :)




Comment at: include/__config:1267
+# if defined(_DLL) && !defined(_LIBCPP_BUILDING_LIBRARY)
+#   if defined(_LIBCPP_DEBUG)
+# pragma comment(lib, "c++d.lib")

compnerd wrote:
> smeenai wrote:
> > I guess `_DLL` is appropriate here. Ideally though I think adding the 
> > pragma should be keyed on exactly the same conditional that determines 
> > whether we annotate with dllexport/dllimport, and right now that's only 
> > conditional on `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.
> Its more complicated.  This is for the *user* not the library itself.  When 
> building the shared library we need to ensure that it is not added 
> (`!defined(_LIBCPP_BUILDING_LIBRARY)`).  When using the headers as a user, 
> the `_DLL` tells you about the dynamic/static behavior.
I know, but the dllimport annotations are also for the *user*. If you're 
getting the dllimport annotations, you should also be getting the pragma, and 
vice-versa.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40660



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added a comment.
This revision now requires changes to proceed.

very minor comments




Comment at: clangd/ClangdServer.h:288
+  /// Get document highlights for a symbol hovered on.
+  llvm::Expected>>
+  findDocumentHighlights(PathRef File, Position Pos);

"for a symbol hovered on."

It doesn't have to be a symbol and the user doesn't have to hover on it. So 
maybe just "for a given position"



Comment at: clangd/ClangdUnit.cpp:1088
+  SourceLocation LocStart = ValSourceRange.getBegin();
+  SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(), 
0,
+ SourceMgr, LangOpts);

  const FileEntry *F = 
SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart));
  if (!F)
return llvm::None;



Comment at: clangd/ClangdUnit.cpp:1098
+  Location L;
+  if (const FileEntry *F =
+  SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {

maybe move the check earlier? see comment above.



Comment at: clangd/Protocol.h:601
+
+/**
+ * A document highlight is a range inside a text document which deserves

Use /// like other structs


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-11-30 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

There is no way to apply sanitizer suppressions to ObjC blocks. A
reasonable default is to have blocks inherit their parent's sanitizer
options.

rdar://32769634


https://reviews.llvm.org/D40668

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjC/no-sanitize.m


Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck 
%s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;


Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck %s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/ClangdLSPServer.cpp:228
 llvm::toString(Items.takeError()));
+
   C.reply(json::ary(Items->Value));

remove extra line



Comment at: clangd/ClangdUnit.cpp:1054
+return llvm::errc::no_such_file_or_directory;
+  } else {
+FileID FID = AST.getASTContext().getSourceManager().translateFile(F);

else is not needed because it returns in the if



Comment at: clangd/ClangdUnit.cpp:1080
+return llvm::errc::no_such_file_or_directory;
+  } else {
+SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(),

else is not needed since you return in the if



Comment at: clangd/ClangdUnit.cpp:1209
+H.range = L->range;
+  else
+H.range = Range();

```
 else
H.range = Range();
```
Remove this, once the bug in Protocol.cpp is fixed, the Range will be truly 
optional.



Comment at: clangd/ClangdUnit.cpp:1247
+H.range = L->range;
+  else
+H.range = Range();

```
 else
H.range = Range();
```
Remove this, once the bug in Protocol.cpp is fixed, the Range will be truly 
optional.



Comment at: clangd/ClangdUnit.cpp:1505
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
-  /*StoreInMemory=*/That->StorePreamblesInMemory,
-  SerializedDeclsCollector);
+  /*StoreInMemory=*/true, SerializedDeclsCollector);
 

revert this change



Comment at: clangd/Protocol.cpp:498
+// Default Hover values
+Hover H;
+return json::obj{

remove, we have to return the contents of the H that was passed as parameter, 
not a new one. I hit this bug while testing with no range (hover text in 
another file)

So this should be
```
if (H.range.hasValue()) {
return json::obj{
{"contents", json::ary(H.contents)},
{"range", H.range.getValue()},
};
  }

  return json::obj{
{"contents", json::ary(H.contents)},
};
```



Comment at: clangd/Protocol.h:26
 #include "llvm/ADT/Optional.h"
-#include 
+#include "llvm/Support/YAMLParser.h"
 #include 

revert this change?



Comment at: clangd/Protocol.h:463
+
+  /**
+   * The hover's content

Documentation should use /// like the others



Comment at: clangd/Protocol.h:468
+
+  /**
+   * An optional range is a range inside a text document

Documentation should use /// like the others


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D35894



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-11-30 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/ClangdServer.cpp:526
+if (!AST)
+  llvm::make_error(
+  "invalid AST",

missing return?
I get a warning that looks legit:
./tools/clang/tools/extra/clangd/ClangdServer.cpp:526:7: warning: ignoring 
return value of function declared with 'warn_unused_result' attribute 
[-Wunused-result]
  llvm::make_error(



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38425



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


[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

2017-11-30 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine closed this revision.
saugustine added a comment.

Committed as https://reviews.llvm.org/rL319474.


https://reviews.llvm.org/D36431



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


[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Anton via Phabricator via cfe-commits
xgsa created this revision.
xgsa added a project: clang-tools-extra.

The NOLINT directive was extended to support the "NOLINT(category)" and 
"NOLINT(*)" syntax. Also it is possible to specify a few categories separated 
with comma "NOLINT(cat1, cat2)"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,8 +13,17 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-category)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-category, google-explicit-constructor)
+
 void f() {
   int i;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' [clang-diagnostic-unused-variable]
@@ -35,4 +44,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 11 warnings (11 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,10 +4,23 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-category)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
 
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-category, google-explicit-constructor)
+class C4 { C4(int i); };
+
+
 // NOLINTNEXTLINE
 
 class D { D(int i); };
@@ -28,6 +41,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "llvm/ADT/SmallString.h"
+#include 
 #include 
 #include 
 using namespace clang;
@@ -289,8 +290,37 @@
   LastErrorRelatesToUserCode = false;
   LastErrorPassesLineFilter = false;
 }
-
-static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext &Context) {
+  const auto NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+auto BracketIndex = NolintIndex + NolintMacro.size();
+if (BracketIndex < Line.size() && Line[BracketIndex] == '(') {
+  ++BracketIndex;
+  const auto BracketEndIndex = Line.find(')', BracketIndex);
+  if (BracketEndIndex != StringRef::npos) {
+auto ChecksStr =
+Line.substr(BracketIndex, BracketEndIndex - BracketIndex);
+if (ChecksStr != "*") {
+  auto CheckName = Context.getCheckName(DiagID);
+  // Allow specifying a few check names, delimited with comma
+  SmallVector Checks;
+  ChecksStr.split(Checks, ',', -1, false);
+  for (auto &Check : Checks) {
+Check = Check.trim();
+  }
+  return std::find(Checks.begin(), Checks.end(), CheckName) !=
+ Checks.end();
+}
+  }
+}
+return true;
+  }
+  return false;
+}
+static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc,
+   unsigned DiagID,
+   const ClangTidyContext &Context) {
   bool Invalid;
   const char *CharacterData = SM.getCharacterData(Loc, &Invalid);
   if (Invalid)
@@ -301,8 +331,7 @@
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-  // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-  if (RestOfLine.find("NOLINT") != StringRef::npos)
+  if (IsNOLINTFound("NOLINT", RestOfLine, DiagID, Context))
 return true;
 
   // Check if there's a NOLINTNEXTLINE on the previous line.
@@ -329,16 +358,17 @@
 --P;
 
   RestOfLine = StringRef(P, LineEnd -

[PATCH] D40580: [clang-tidy] Adding Fuchsia checker for multiple inheritance

2017-11-30 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 125000.
juliehockett marked 4 inline comments as done.

https://reviews.llvm.org/D40580

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
  clang-tidy/fuchsia/MultipleInheritanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-multiple-inheritance.cpp

Index: test/clang-tidy/fuchsia-multiple-inheritance.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+
+class Base_A {
+public:
+  virtual int foo() { return 0; }
+};
+
+class Base_B {
+public:
+  virtual int bar() { return 0; }
+};
+
+class Base_A_child : public Base_A {
+public:
+  virtual int baz() { return 0; }
+};
+
+class Interface_A {
+public:
+  virtual int foo() = 0;
+};
+
+class Interface_B {
+public:
+  virtual int bar() = 0;
+};
+
+class Interface_C {
+public:
+  virtual int blat() = 0;
+};
+
+class Interface_A_with_member {
+public:
+  virtual int foo() = 0;
+  int val = 0;
+};
+
+class Interface_with_A_Parent : public Base_A {
+public:
+  virtual int baz() = 0;
+};
+
+// Inherits from multiple concrete classes.
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
+class Bad_Child1 : public Base_A, Base_B {};
+
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+class Bad_Child2 : public Base_A, Interface_A_with_member {
+  virtual int foo() override { return 0; }
+};
+
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes which aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+class Bad_Child3 : public Interface_with_A_Parent, Base_B {
+  virtual int baz() override { return 0; }
+};
+
+// Easy cases of single inheritance
+class Simple_Child1 : public Base_A {};
+class Simple_Child2 : public Interface_A {
+  virtual int foo() override { return 0; }
+};
+
+// Valid uses of multiple inheritance
+class Good_Child1 : public Interface_A, Interface_B {
+  virtual int foo() override { return 0; }
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child2 : public Base_A, Interface_B {
+  virtual int bar() override { return 0; }
+};
+
+class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
+  virtual int bar() override { return 0; }
+  virtual int blat() override { return 0; }
+};
+
+int main(void) {
+  Bad_Child1 a;
+  Bad_Child2 b;
+  Bad_Child3 c;
+  Simple_Child1 d;
+  Simple_Child2 e;
+  Good_Child1 f;
+  Good_Child2 g;
+  Good_Child3 h;
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
fuchsia-default-arguments
+   fuchsia-multiple-inheritance
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-multiple-inheritance.rst
@@ -0,0 +1,46 @@
+.. title:: clang-tidy - fuchsia-multiple-inheritance
+
+fuchsia-multiple-inheritance
+
+
+Warns if a class inherits from multiple classes that are not pure virtual.
+
+For example, declaring a class that inherits from multiple concrete classes is
+disallowed:
+
+.. code-block:: c++
+
+  class Base_A {
+  public:
+virtual int foo() { return 0; }
+  };
+
+  class Base_B {
+  public:
+virtual int bar() { return 0; }
+  };
+
+  // Warning
+  class Bad_Child1 : public Base_A, Base_B {};
+
+A class that inherits from a pure virtual is allowed:
+
+.. code-block:: c++
+
+  class Interface_A {
+  public:
+virtual int foo() = 0;
+  };
+
+  class Interface_B {
+  public:
+virtual int bar() = 0;
+  };
+
+  // No warning
+  class Good_Child1 : public Interface_A, Interface_B {
+virtual int foo() override { return 0; }
+virtual int bar() override { return 0; }
+  };
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -135,6 +135,11 @@
 
   Warns if a function or method is declared or called with default arguments.
 
+- New `fuchsia-multiple-inheritance

[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added a project: clang.

Fedora27 is using a new version of glibc that refers to the _Float128 type. 
This patch adds that name as an alias to __float128. I also added some 
predefined macro values for the digits, mantissa, epilon, etc (FloatMacros).  
For the test case, I copied an existing __float128 test.  This functionality 
needs work long term, but it should be sufficient to tread water for a while.  
At Intel we have test servers running our LLVM compiler with various open 
source workloads, the server has been upgraded to Fedora27 so many workloads 
are failing due to _Float128. What do you think?


https://reviews.llvm.org/D40673

Files:
  include/clang/Basic/TokenKinds.def
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/cuda-types.cu
  test/Sema/_Float128.cpp

Index: test/Sema/_Float128.cpp
===
--- /dev/null
+++ test/Sema/_Float128.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
+
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+_Float128 f;
+_Float128 tiny = __FLT128_EPSILON__;
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};
+int g(int x, _Float128 *y) {
+  return x + *y;
+}
+
+// expected-no-diagnostics
+#else
+#if !defined(__STRICT_ANSI__)
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};  // expected-error {{__float128 is not supported on this target}}
+
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
+}
+
+#else
+_Float128 f;  // expected-error {{__float128 is not supported on this target}}
+template struct __is_floating_point_helper {};
+template<> struct __is_floating_point_helper<_Float128> {};  // expected-error {{__float128 is not supported on this target}}
+
+int g(int x, _Float128 *y) {  // expected-error {{__float128 is not supported on this target}}
+  return x + *y;
+}
+
+#endif  // !defined(__STRICT_ANSI__)
+#endif  // defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
Index: test/Preprocessor/cuda-types.cu
===
--- test/Preprocessor/cuda-types.cu
+++ test/Preprocessor/cuda-types.cu
@@ -9,40 +9,40 @@
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
 // RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
 // RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
+// RUN:   | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/po

[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please upload patches with full context (`-U99`)
Also, you probably want to add some reviewers, see CODE_OWNERS.txt e.g.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671



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


[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clangd/JSONExpr.h:71
+// The convention is to have a deserialize function findable via ADL:
+// deserialize(const json::Expr&, T&)->bool
+// Deserializers are provided for:

ilya-biryukov wrote:
> The name `deserialize` may be a bit too general and prone to clashes with 
> other code. Maybe choosing something a bit more specific like 
> `json_deserialize` is a better option.
> On the other hand, we do the SFINAE trick to check the types are correct in 
> `Expr` constructor, so we should be fine either way.
Yeah, these are a bit generic. Renamed to `toJSON`/`fromJSON` - not perfect 
names but they're short and I find it easier to remember which direction they 
convert in.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40596



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


[clang-tools-extra] r319478 - [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov 30 13:32:29 2017
New Revision: 319478

URL: http://llvm.org/viewvc/llvm-project?rev=319478&view=rev
Log:
[clangd] New conventions for JSON-marshalling functions, centralize machinery

Summary:
 - JSON<->Obj interface is now ADL functions, so they play nicely with enums
 - recursive vector/map parsing and ObjectMapper moved to JSONExpr and tested
 - renamed (un)parse to (de)serialize, since text -> JSON is called parse
 - Protocol.cpp gets a bit shorter

Sorry for the giant patch, it's prety mechanical though

Reviewers: ilya-biryukov

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/JSONExpr.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/test/clangd/trace.test
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=319478&r1=319477&r2=319478&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Nov 30 13:32:29 2017
@@ -117,7 +117,7 @@ void ClangdLSPServer::onCommand(Ctx C, E
 // We don't need the response so id == 1 is OK.
 // Ideally, we would wait for the response and if there is no error, we
 // would reply success/failure to the original RPC.
-C.call("workspace/applyEdit", 
ApplyWorkspaceEditParams::unparse(ApplyEdit));
+C.call("workspace/applyEdit", ApplyEdit);
   } else {
 // We should not get here because ExecuteCommandParams would not have
 // parsed in the first place and this handler should not be called. But if
@@ -140,7 +140,7 @@ void ClangdLSPServer::onRename(Ctx C, Re
   std::vector Edits = replacementsToEdits(Code, *Replacements);
   WorkspaceEdit WE;
   WE.changes = {{Params.textDocument.uri.uri, Edits}};
-  C.reply(WorkspaceEdit::unparse(WE));
+  C.reply(WE);
 }
 
 void ClangdLSPServer::onDocumentDidClose(Ctx C,

Modified: clang-tools-extra/trunk/clangd/JSONExpr.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONExpr.h?rev=319478&r1=319477&r2=319478&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONExpr.h (original)
+++ clang-tools-extra/trunk/clangd/JSONExpr.h Thu Nov 30 13:32:29 2017
@@ -36,7 +36,7 @@ namespace json {
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@ namespace json {
 //   if (Optional Font = Opts->getString("font"))
 // assert(Opts->at("font").kind() == Expr::String);
 //
+// === Converting expressions to objects ===
+//
+// The convention is to have a deserializer function findable via ADL:
+// fromJSON(const json::Expr&, T&)->bool
+// Deserializers are provided for:
+//   - bool
+//   - int
+//   - double
+//   - std::string
+//   - vector, where T is deserializable
+//   - map, where T is deserializable
+//   - Optional, where T is deserializable
+//
+// ObjectMapper can help writing fromJSON() functions for object types:
+//   bool fromJSON(const Expr &E, MyStruct &R) {
+// ObjectMapper O(E);
+// if (!O || !O.map("mandatory_field", R.MandatoryField))
+//   return false;
+// O.map("optional_field", R.OptionalField);
+// return true;
+//   }
+//
 // === Serialization ===
 //
 // Exprs can be serialized to JSON:
@@ -127,12 +149,11 @@ public:
   Expr(T D) : Type(T_Number) {
 create(D);
   }
-  // Types with a static T::unparse function returning an Expr.
-  // FIXME: should this be a free unparse() function found by ADL?
+  // Types with a toJSON(const T&)->Expr function, found by ADL.
   template ::value>>
-  Expr(const T &V) : Expr(T::unparse(V)) {}
+Expr, decltype(toJSON(*(const T *)nullptr))>::value>>
+  Expr(const T &V) : Expr(toJSON(V)) {}
 
   Expr &operator=(const Expr &M) {
 destroy();
@@ -432,6 +453,101 @@ inline Expr::ObjectExpr::ObjectExpr(std:
 using obj = Expr::ObjectExpr;
 using ary = Expr::ArrayExpr;
 
+// Standard deserializers.
+inline bool fromJSON(const json::Expr &E, std::string &Out) {
+  if (auto S = E.asString()) {
+Out = *S;
+return true;
+  }
+  return false;
+}
+inline bool fromJSON(const json::Expr &E, int &Out) {
+  if (auto S = E.asInteger()) {
+Out = *S;
+return true;
+  }
+  return false;
+}
+inline bool fromJSON(const json:

[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rCTE319478: [clangd] New conventions for JSON-marshalling 
functions, centralize machinery (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D40596?vs=124715&id=125003#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40596

Files:
  clangd/ClangdLSPServer.cpp
  clangd/JSONExpr.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  test/clangd/trace.test
  unittests/clangd/JSONExprTests.cpp

Index: unittests/clangd/JSONExprTests.cpp
===
--- unittests/clangd/JSONExprTests.cpp
+++ unittests/clangd/JSONExprTests.cpp
@@ -229,6 +229,64 @@
   }
 }
 
+// Sample struct with typical JSON-mapping rules.
+struct CustomStruct {
+  CustomStruct() : B(false) {}
+  CustomStruct(std::string S, llvm::Optional I, bool B)
+  : S(S), I(I), B(B) {}
+  std::string S;
+  llvm::Optional I;
+  bool B;
+};
+inline bool operator==(const CustomStruct &L, const CustomStruct &R) {
+  return L.S == R.S && L.I == R.I && L.B == R.B;
+}
+inline std::ostream &operator<<(std::ostream &OS, const CustomStruct &S) {
+  return OS << "(" << S.S << ", " << (S.I ? std::to_string(*S.I) : "None")
+<< ", " << S.B << ")";
+}
+bool fromJSON(const json::Expr &E, CustomStruct &R) {
+  ObjectMapper O(E);
+  if (!O || !O.map("str", R.S) || !O.map("int", R.I))
+return false;
+  O.map("bool", R.B);
+  return true;
+}
+
+TEST(JSONTest, Deserialize) {
+  std::map> R;
+  CustomStruct ExpectedStruct = {"foo", 42, true};
+  std::map> Expected;
+  Expr J = obj{{"foo", ary{
+   obj{
+   {"str", "foo"},
+   {"int", 42},
+   {"bool", true},
+   {"unknown", "ignored"},
+   },
+   obj{{"str", "bar"}},
+   obj{
+   {"str", "baz"},
+   {"bool", "string"}, // OK, deserialize ignores.
+   },
+   }}};
+  Expected["foo"] = {
+  CustomStruct("foo", 42, true),
+  CustomStruct("bar", llvm::None, false),
+  CustomStruct("baz", llvm::None, false),
+  };
+  ASSERT_TRUE(fromJSON(J, R));
+  EXPECT_EQ(R, Expected);
+
+  CustomStruct V;
+  EXPECT_FALSE(fromJSON(nullptr, V)) << "Not an object " << V;
+  EXPECT_FALSE(fromJSON(obj{}, V)) << "Missing required field " << V;
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}}, V)) << "Wrong type " << V;
+  // Optional must parse as the correct type if present.
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}, {"int", "string"}}, V))
+  << "Wrong type for Optional " << V;
+}
+
 } // namespace
 } // namespace json
 } // namespace clangd
Index: clangd/JSONExpr.h
===
--- clangd/JSONExpr.h
+++ clangd/JSONExpr.h
@@ -36,7 +36,7 @@
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@
 //   if (Optional Font = Opts->getString("font"))
 // assert(Opts->at("font").kind() == Expr::String);
 //
+// === Converting expressions to objects ===
+//
+// The convention is to have a deserializer function findable via ADL:
+// fromJSON(const json::Expr&, T&)->bool
+// Deserializers are provided for:
+//   - bool
+//   - int
+//   - double
+//   - std::string
+//   - vector, where T is deserializable
+//   - map, where T is deserializable
+//   - Optional, where T is deserializable
+//
+// ObjectMapper can help writing fromJSON() functions for object types:
+//   bool fromJSON(const Expr &E, MyStruct &R) {
+// ObjectMapper O(E);
+// if (!O || !O.map("mandatory_field", R.MandatoryField))
+//   return false;
+// O.map("optional_field", R.OptionalField);
+// return true;
+//   }
+//
 // === Serialization ===
 //
 // Exprs can be serialized to JSON:
@@ -127,12 +149,11 @@
   Expr(T D) : Type(T_Number) {
 create(D);
   }
-  // Types with a static T::unparse function returning an Expr.
-  // FIXME: should this be a free unparse() function found by ADL?
+  // Types with a toJSON(const T&)->Expr function, found by ADL.
   template ::value>>
-  Expr(const T &V) : Expr(T::unparse(V)) {}
+Expr, decltype(toJSON(*(const T *)nullptr))>::value>>
+  Expr(const T &V) : Expr(toJSON(V)) {}
 
   Expr &operator=(const Expr &M) {
 destroy();
@@ -432,6 +453,101 @@
 using obj = Expr::ObjectExpr;
 using ary = Expr::ArrayExpr;
 
+// Standard deserializers.
+inline bool fromJSON(const json::Expr &E, std::

[PATCH] D40596: [clangd] New conventions for JSON-marshalling functions, centralize machinery

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319478: [clangd] New conventions for JSON-marshalling 
functions, centralize machinery (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D40596?vs=124715&id=125004#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40596

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/JSONExpr.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/test/clangd/trace.test
  clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
@@ -229,6 +229,64 @@
   }
 }
 
+// Sample struct with typical JSON-mapping rules.
+struct CustomStruct {
+  CustomStruct() : B(false) {}
+  CustomStruct(std::string S, llvm::Optional I, bool B)
+  : S(S), I(I), B(B) {}
+  std::string S;
+  llvm::Optional I;
+  bool B;
+};
+inline bool operator==(const CustomStruct &L, const CustomStruct &R) {
+  return L.S == R.S && L.I == R.I && L.B == R.B;
+}
+inline std::ostream &operator<<(std::ostream &OS, const CustomStruct &S) {
+  return OS << "(" << S.S << ", " << (S.I ? std::to_string(*S.I) : "None")
+<< ", " << S.B << ")";
+}
+bool fromJSON(const json::Expr &E, CustomStruct &R) {
+  ObjectMapper O(E);
+  if (!O || !O.map("str", R.S) || !O.map("int", R.I))
+return false;
+  O.map("bool", R.B);
+  return true;
+}
+
+TEST(JSONTest, Deserialize) {
+  std::map> R;
+  CustomStruct ExpectedStruct = {"foo", 42, true};
+  std::map> Expected;
+  Expr J = obj{{"foo", ary{
+   obj{
+   {"str", "foo"},
+   {"int", 42},
+   {"bool", true},
+   {"unknown", "ignored"},
+   },
+   obj{{"str", "bar"}},
+   obj{
+   {"str", "baz"},
+   {"bool", "string"}, // OK, deserialize ignores.
+   },
+   }}};
+  Expected["foo"] = {
+  CustomStruct("foo", 42, true),
+  CustomStruct("bar", llvm::None, false),
+  CustomStruct("baz", llvm::None, false),
+  };
+  ASSERT_TRUE(fromJSON(J, R));
+  EXPECT_EQ(R, Expected);
+
+  CustomStruct V;
+  EXPECT_FALSE(fromJSON(nullptr, V)) << "Not an object " << V;
+  EXPECT_FALSE(fromJSON(obj{}, V)) << "Missing required field " << V;
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}}, V)) << "Wrong type " << V;
+  // Optional must parse as the correct type if present.
+  EXPECT_FALSE(fromJSON(obj{{"str", 1}, {"int", "string"}}, V))
+  << "Wrong type for Optional " << V;
+}
+
 } // namespace
 } // namespace json
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
===
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
@@ -21,7 +21,7 @@
 // Helper for attaching ProtocolCallbacks methods to a JSONRPCDispatcher.
 // Invoke like: Registerer("foo", &ProtocolCallbacks::onFoo)
 // onFoo should be: void onFoo(Ctx &C, FooParams &Params)
-// FooParams should have a static factory method: parse(const json::Expr&).
+// FooParams should have a fromJSON function.
 struct HandlerRegisterer {
   template 
   void operator()(StringRef Method,
@@ -31,11 +31,9 @@
 auto *Callbacks = this->Callbacks;
 Dispatcher.registerHandler(
 Method, [=](RequestContext C, const json::Expr &RawParams) {
-  if (auto P = [&] {
-trace::Span Tracer("Parse");
-return std::decay::type::parse(RawParams);
-  }()) {
-(Callbacks->*Handler)(std::move(C), *P);
+  typename std::remove_reference::type P;
+  if (fromJSON(RawParams, P)) {
+(Callbacks->*Handler)(std::move(C), P);
   } else {
 Out->log("Failed to decode " + Method + " request.\n");
   }
Index: clang-tools-extra/trunk/clangd/JSONExpr.h
===
--- clang-tools-extra/trunk/clangd/JSONExpr.h
+++ clang-tools-extra/trunk/clangd/JSONExpr.h
@@ -36,7 +36,7 @@
 //   - booleans
 //   - null: nullptr
 //   - arrays: {"foo", 42.0, false}
-//   - serializable things: any T with a T::unparse(const T&) -> Expr
+//   - serializable things: types with toJSON(const T&)->Expr, found by ADL
 //
 // They can also be constructed from object/array helpers:
 //   - json::obj is a type like map
@@ -65,6 +65,28 @@
 //   if (Optional Font = Opts->getSt

[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

LGTM for the CUDA test changes.


https://reviews.llvm.org/D40673



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


[PATCH] D40654: [clangd] Set completion options per-request.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Nice!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40654



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


[clang-tools-extra] r319479 - [Documentation] Style fixes for Objective-C checks documentation to follow C/C++ example.

2017-11-30 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Nov 30 13:42:27 2017
New Revision: 319479

URL: http://llvm.org/viewvc/llvm-project?rev=319479&view=rev
Log:
[Documentation] Style fixes for Objective-C checks documentation to follow 
C/C++ example.

Release Notes should just repeat first sentence from documentation.

Remove duplicated entry from Release Notes.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-nserror-init.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/objc-forbidden-subclassing.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=319479&r1=319478&r2=319479&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Nov 30 13:42:27 2017
@@ -57,11 +57,6 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New `objc-avoid-nserror-init
-  
`_ 
check
-
-  Add new check to detect the use of [NSError init].
-
 - New module `fuchsia` for Fuchsia style checks.
 
 - New module `objc` for Objective-C style checks.
@@ -143,13 +138,13 @@ Improvements to clang-tidy
 - New `google-objc-avoid-throwing-exception
   
`_
 check
 
-  Add new check to detect throwing exceptions in Objective-C code, which 
should be avoided.
+  Finds uses of throwing exceptions usages in Objective-C files.
 
 - New `google-objc-global-variable-declaration
   
`_
 check
 
-  Add new check for Objective-C code to ensure global variables follow the
-  naming convention of 'k[A-Z].*' (for constants) or 'g[A-Z].*' (for 
variables).
+  Finds global variable declarations in Objective-C files that do not follow 
the
+  pattern of variable names in Google's Objective-C Style Guide.
 
 - New `hicpp-exception-baseclass
   
`_
 check
@@ -166,7 +161,7 @@ Improvements to clang-tidy
 - New `objc-avoid-nserror-init
   
`_ 
check
 
-  Add new check to detect the use of [NSError init].
+  Finds improper initialization of ``NSError`` objects.
 
 - New `objc-avoid-spinlock
   `_ 
check
@@ -177,15 +172,14 @@ Improvements to clang-tidy
 - New `objc-forbidden-subclassing
   
`_
 check
 
-  Ensures Objective-C classes do not subclass any classes which are
-  not intended to be subclassed. Includes a list of classes from Foundation
-  and UIKit which are documented as not supporting subclassing.
+  Finds Objective-C classes which are subclasses of classes which are not
+  designed to be subclassed.
 
 - New `objc-property-declaration
   
`_
 check
 
-  Add new check for Objective-C code to ensure property names follow the naming
-  convention of Apple's programming guide.
+  Finds property declarations in Objective-C files that do not follow the
+  pattern of property names in Apple's programming guide.
 
 - New `readability-static-accessed-through-instance
   
`_
 check
@@ -245,6 +239,7 @@ Improvements to clang-tidy
   
`_
 
 The check's options were renamed as follows:
+
 - `AllowConditionalIntegerCasts` -> `AllowIntegerConditions`,
 - `AllowConditionalPointerCasts` -> `AllowPointerConditions`.
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst?rev=319479&r1=319478&r2=319479&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-objc-avoid-throwing-exception.rst
 Thu Nov 30 13:42:27 2017
@@ -3,7 +3,8 @@
 google-objc-avoid-throwing-exception
 ==

[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Per https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html, this doesn't appear 
to be correct: `_Float128` is only *sometimes* the same type as `__float128`.


https://reviews.llvm.org/D40673



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


[PATCH] D40671: Support specific categories for NOLINT directive

2017-11-30 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 125008.
xgsa added a reviewer: dcoughlin.
xgsa added a comment.

Update the diff to contain the full context


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,16 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-category)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-category, google-explicit-constructor)
 
 void f() {
   int i;
@@ -35,4 +44,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 11 warnings (11 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,21 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-category)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-category, google-explicit-constructor)
+class C4 { C4(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +41,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 4 warnings (4 NOLINT)
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
 
 // RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "llvm/ADT/SmallString.h"
+#include 
 #include 
 #include 
 using namespace clang;
@@ -289,8 +290,37 @@
   LastErrorRelatesToUserCode = false;
   LastErrorPassesLineFilter = false;
 }
-
-static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
+static bool IsNOLINTFound(StringRef NolintMacro, StringRef Line,
+  unsigned DiagID, const ClangTidyContext &Context) {
+  const auto NolintIndex = Line.find(NolintMacro);
+  if (NolintIndex != StringRef::npos) {
+auto BracketIndex = NolintIndex + NolintMacro.size();
+if (BracketIndex < Line.size() && Line[BracketIndex] == '(') {
+  ++BracketIndex;
+  const auto BracketEndIndex = Line.find(')', BracketIndex);
+  if (BracketEndIndex != StringRef::npos) {
+auto ChecksStr =
+Line.substr(BracketIndex, BracketEndIndex - BracketIndex);
+if (ChecksStr != "*") {
+  auto CheckName = Context.getCheckName(DiagID);
+  // Allow specifying a few check names, delimited with comma
+  SmallVector Checks;
+  ChecksStr.split(Checks, ',', -1, false);
+  for (auto &Check : Checks) {
+Check = Check.trim();
+  }
+  return std::find(Checks.begin(), Checks.end(), CheckName) !=
+ Checks.end();
+}
+  }
+}
+return true;
+  }
+  return false;
+}
+static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc,
+   unsigned DiagID,
+   const ClangTidyContext &Context) {
   bool Invalid;
   const char *CharacterData = SM.getCharacterData(Loc, &Invalid);
   if (Invalid)
@@ -301,8 +331,7 @@
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-  // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-  if (RestOfLine.find("NOLINT") != StringRef::npos)
+  if (IsNOLINTFound("NOLINT", RestOfLine, DiagID, Context))
 return true;
 
   // Check if there's a NOLINTNEXTLINE on the previous line.
@@ -329,16 +358,17 @@
 --P;
 
   RestOfLine = StringRef(P, LineEnd - P + 1);
-  if (RestOfLine.find("NOLINTNEXTLINE") != StringRef::npos)
+  if (IsNOLINTFound("NOLINTNEXTLINE", RestOfLine, DiagID, Context))
 return true;
 
   return false;
 }
 
-static bool LineIsMarkedWithNOLINTinMacro(SourceManager

[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 125009.
sammccall added a comment.
Herald added a subscriber: klimek.

Rebase and remove debug output.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39882

Files:
  clangd/ClangdUnit.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -742,6 +742,61 @@
   EXPECT_FALSE(ContainsItem(Results, "CCC"));
 }
 
+TEST_F(ClangdCompletionTest, Filter) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true, Opts,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  const char *Body = R"cpp(
+int Abracadabra;
+int Alakazam;
+struct S {
+  int FooBar;
+  int FooBaz;
+  int Qux;
+};
+  )cpp";
+  auto Complete = [&](StringRef Query) {
+StringWithPos Completion = parseTextMarker(
+formatv("{0} int main() { {1}{{complete}} }", Body, Query).str(),
+"complete");
+Server.addDocument(FooCpp, Completion.Text);
+return Server
+.codeComplete(FooCpp, Completion.MarkerPos, StringRef(Completion.Text))
+.get()
+.Value;
+  };
+
+  auto Foba = Complete("S().Foba");
+  EXPECT_TRUE(ContainsItem(Foba, "FooBar"));
+  EXPECT_TRUE(ContainsItem(Foba, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(Foba, "Qux"));
+
+  auto FR = Complete("S().FR");
+  EXPECT_TRUE(ContainsItem(FR, "FooBar"));
+  EXPECT_FALSE(ContainsItem(FR, "FooBaz"));
+  EXPECT_FALSE(ContainsItem(FR, "Qux"));
+
+  auto Op = Complete("S().opr");
+  EXPECT_TRUE(ContainsItem(Op, "operator="));
+
+  auto Aaa = Complete("aaa");
+  EXPECT_TRUE(ContainsItem(Aaa, "Abracadabra"));
+  EXPECT_TRUE(ContainsItem(Aaa, "Alakazam"));
+
+  auto UA = Complete("_a");
+  EXPECT_TRUE(ContainsItem(UA, "static_cast"));
+  EXPECT_FALSE(ContainsItem(UA, "Abracadabra"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -446,13 +446,16 @@
   void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override final {
+StringRef Filter = S.getPreprocessor().getCodeCompletionFilter();
 std::priority_queue Candidates;
 for (unsigned I = 0; I < NumResults; ++I) {
   auto &Result = Results[I];
   if (!ClangdOpts.IncludeIneligibleResults &&
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
+  if (!Filter.empty() && !fuzzyMatch(S, Context, Filter, Result))
+continue;
   Candidates.emplace(Result);
   if (ClangdOpts.Limit && Candidates.size() > ClangdOpts.Limit) {
 Candidates.pop();
@@ -476,6 +479,39 @@
   CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
 
 private:
+  bool fuzzyMatch(Sema &S, const CodeCompletionContext &CCCtx, StringRef Filter,
+  CodeCompletionResult Result) {
+switch (Result.Kind) {
+case CodeCompletionResult::RK_Declaration:
+  if (auto *ID = Result.Declaration->getIdentifier())
+return fuzzyMatch(Filter, ID->getName());
+  break;
+case CodeCompletionResult::RK_Keyword:
+  return fuzzyMatch(Filter, Result.Keyword);
+case CodeCompletionResult::RK_Macro:
+  return fuzzyMatch(Filter, Result.Macro->getName());
+case CodeCompletionResult::RK_Pattern:
+  return fuzzyMatch(Filter, Result.Pattern->getTypedText());
+}
+auto *CCS = Result.CreateCodeCompletionString(
+S, CCCtx, *Allocator, CCTUInfo, /*IncludeBriefComments=*/false);
+return fuzzyMatch(Filter, CCS->getTypedText());
+  }
+
+  // Checks whether Target matches the Filter.
+  // Currently just requires a case-insensitive subsequence match.
+  // FIXME: make stricter and word-based: 'unique_ptr' should not match 'que'.
+  // FIXME: return a score to be incorporated into ranking.
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+size_t TPos = 0;
+for (char C : Filter) {
+  TPos = Target.find_lower(C, TPos);
+  if (TPos == StringRef::npos)
+return false;
+}
+return true;
+  }
+
   CompletionItem
   ProcessCodeCompleteResult(const CompletionCandidate &Candidate,
 const Code

[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@ilya-biryukov Ping... this is the patch we wanted to land this week, so long 
result sets are correct for user testing next week.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39882



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@ilya-biryukov We should get this landed.
I'm happy (my comments were addressed a few rounds ago) - any concerns?


https://reviews.llvm.org/D39430



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


[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

Use this function to create the install targets rather than doing so
manually, which gains us the `-stripped` install targets to perform
stripped installations.


Repository:
  rC Clang

https://reviews.llvm.org/D40675

Files:
  cmake/modules/AddClang.cmake
  lib/Headers/CMakeLists.txt
  runtime/CMakeLists.txt
  tools/c-index-test/CMakeLists.txt
  tools/libclang/CMakeLists.txt

Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -148,9 +148,6 @@
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-libclang-headers
-DEPENDS
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=libclang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-libclang-headers
+   COMPONENT libclang-headers)
 endif()
Index: tools/c-index-test/CMakeLists.txt
===
--- tools/c-index-test/CMakeLists.txt
+++ tools/c-index-test/CMakeLists.txt
@@ -56,10 +56,8 @@
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=c-index-test
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-c-index-test
+ DEPENDS c-index-test
+ COMPONENT c-index-test)
   endif()
 endif()
Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -101,12 +101,9 @@
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -141,9 +141,7 @@
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()
Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -104,11 +104,9 @@
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> _Float128 is only *sometimes* the same type as __float128.

But we don't have hppa or IA-64 backends, so we're fine for now, I think. :)




Comment at: lib/Frontend/InitPreprocessor.cpp:817
   DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
+  DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q");
+

We should have a FIXME here to switch away from the non-standard "Q" when we 
can.


https://reviews.llvm.org/D40673



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


[PATCH] D40486: [clangd] Implemented logging using Context

2017-11-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This is pretty bikesheddy, but I wonder what you think about passing Ctx as the 
first vs last parameter.
First has some advantages (maybe I just read too much Go though):

- it's a short expr, and F(short, long) tends to format better than F(long, 
short). Particularly with lambdas but also long strings.
- it doesn't interfere with default args

It would be nice if we could be completely uniform here.


https://reviews.llvm.org/D40486



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


[PATCH] D40677: [libcxx] Make std::basic_istream::get 0-terminate input array in case of error.

2017-11-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:

  [...] In any case, if n is greater than zero it then stores a null
  character into the next successive location of the array.

rdar://problem/35566567


https://reviews.llvm.org/D40677

Files:
  libcxx/include/istream
  
libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
  
libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp

Index: libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
===
--- libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
+++ libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
@@ -7,13 +7,23 @@
 //
 //===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& get(char_type* s, streamsize n, char_type delim);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct testbuf
 : public std::basic_streambuf
@@ -67,7 +77,33 @@
 assert(!is.fail());
 assert(std::string(s) == " ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5, '*');
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == "");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(" ");
+std::istream is(&sb);
+char s[5] = "test";
+is.exceptions(std::istream::eofbit | std::istream::badbit);
+try
+{
+is.get(s, 5, '*');
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == " ");
+assert(is.gcount() == 1);
 }
+#endif
 {
 testbuf sb(L"  ** ");
 std::wistream is(&sb);
@@ -95,5 +131,31 @@
 assert(!is.fail());
 assert(std::wstring(s) == L" ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5, L'*');
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L"");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(L" ");
+std::wistream is(&sb);
+wchar_t s[5] = L"test";
+is.exceptions(std::wistream::eofbit | std::wistream::badbit);
+try
+{
+is.get(s, 5, L'*');
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L" ");
+assert(is.gcount() == 1);
 }
+#endif
 }
Index: libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
===
--- libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
+++ libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
@@ -7,13 +7,23 @@
 //
 //===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& get(char_type* s, streamsize n);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct testbuf
 : public std::basic_streambuf
@@ -67,7 +77,33 @@
 assert(!is.fail());
 assert(std::string(s) == " ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.get(s, 5);
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == "");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(" ");
+std::istream is(&sb);
+char s[5] = "test";
+is.exceptions(std::istream::eofbit | std::istr

[PATCH] D40198: [CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

2017-11-30 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319485: [CUDA] Tweak CUDA wrappers to make cuda-9 work with 
libc++ (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D40198?vs=123421&id=125021#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40198

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -270,12 +270,18 @@
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -270,12 +270,18 @@
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r319485 - [CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

2017-11-30 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Nov 30 14:22:21 2017
New Revision: 319485

URL: http://llvm.org/viewvc/llvm-project?rev=319485&view=rev
Log:
[CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

CUDA-9 headers check for specific libc++ version and ifdef out
some of the definitions we need if LIBCPP_VERSION >= 3800.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=319485&r1=319484&r2=319485&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Thu Nov 30 14:22:21 
2017
@@ -270,12 +270,18 @@ static inline __device__ void __brkpt(in
 // include guard from math.h wrapper from libstdc++. We have to undo the header
 // guard temporarily to get the definitions we need.
 #pragma push_macro("_GLIBCXX_MATH_H")
+#pragma push_macro("_LIBCPP_VERSION")
 #if CUDA_VERSION >= 9000
 #undef _GLIBCXX_MATH_H
+// We also need to undo another guard that checks for libc++ 3.8+
+#ifdef _LIBCPP_VERSION
+#define _LIBCPP_VERSION 3700
+#endif
 #endif
 
 #include "math_functions.hpp"
 #pragma pop_macro("_GLIBCXX_MATH_H")
+#pragma pop_macro("_LIBCPP_VERSION")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")
 


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


[PATCH] D40673: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2-26

2017-11-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: test/Sema/_Float128.cpp:1
+// RUN: %clang_cc1 -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -verify -std=c++11 %s

GCC documents that it does not support `_Float128` in C++ mode, and I think 
their decision makes sense:
On various targets, `long double` and `__float128` are not the same type, but 
they decided to mangle them the same under `-mlong-double-128` anyway. They 
also decided to make `__float128` and `_Float128` synonyms in the C mode on at 
least some of those targets.

The unfortunate state of affairs with the mangling may be okay for an extension 
type like `__float128`, but creating that situation with `_Float128` does not 
seem wise. The test here is explicitly C++, so it seems this patch exposes 
`_Float128` in C++ mode in a state that needs more discussion (and, in my 
opinion, one that should not ship).



https://reviews.llvm.org/D40673



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


[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D40675



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


r319487 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-30 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Nov 30 14:33:48 2017
New Revision: 319487

URL: http://llvm.org/viewvc/llvm-project?rev=319487&view=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/CXXInheritance.h
cfe/trunk/include/clang/AST/DeclLookups.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/AST/ExprObjC.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=319487&r1=319486&r2=319487&view=diff
==
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Thu Nov 30 14:33:48 2017
@@ -1,4 +1,4 @@
-//===-- CXXInheritance.h - C++ Inheritance --*- C++ 
-*-===//
+//===- CXXInheritance.h - C++ Inheritance ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -16,19 +16,23 @@
 
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeOrdering.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include 
+#include "llvm/ADT/iterator_range.h"
 #include 
+#include 
+#include 
 
 namespace clang {
-  
-class CXXBaseSpecifier;
-class CXXMethodDecl;
-class CXXRecordDecl;
+
+class ASTContext;
 class NamedDecl;
   
 /// \brief Represents an element in a path from a derived class to a
@@ -66,12 +70,12 @@ struct CXXBasePathElement {
 /// subobject is being used.
 class CXXBasePath : public SmallVector {
 public:
-  CXXBasePath() : Access(AS_public) {}
-
   /// \brief The access along this inheritance path.  This is only
   /// calculated when recording paths.  AS_none is a special value
   /// used to indicate a path which permits no legal access.
-  AccessSpecifier Access;
+  AccessSpecifier Access = AS_public;
+
+  CXXBasePath() = default;
 
   /// \brief The set of declarations found inside this base class
   /// subobject.
@@ -113,8 +117,10 @@ public:
 /// refer to the same base class subobject of type A (the virtual
 /// one), there is no ambiguity.
 class CXXBasePaths {
+  friend class CXXRecordDecl;
+
   /// \brief The type from which this search originated.
-  CXXRecordDecl *Origin;
+  CXXRecordDecl *Origin = nullptr;
   
   /// Paths - The actual set of paths that can be taken from the
   /// derived class to the same base class.
@@ -152,15 +158,13 @@ class CXXBasePaths {
   CXXBasePath ScratchPath;
 
   /// DetectedVirtual - The base class that is virtual.
-  const RecordType *DetectedVirtual;
+  const RecordType *DetectedVirtual = nullptr;
   
   /// \brief Array of the declarations that have been found. This
   /// array is constructed only if needed, e.g., to iterate over the
   /// results within LookupResult.
   std::unique_ptr DeclsFound;
-  unsigned NumDeclsFound;
-  
-  friend class CXXRecordDecl;
+  unsigned NumDeclsFound = 0;
   
   void ComputeDeclsFound();
 
@@ -169,17 +173,16 @@ class CXXBasePaths {
  bool LookupInDependent = false);
 
 public:
-  typedef std::list::iterator paths_iterator;
-  typedef std::list::const_iterator const_paths_iterator;
-  typedef NamedDecl **decl_iterator;
+  using paths_iterator = std::list::iterator;
+  using const_paths_iterator = std::list::const_iterator;
+  using decl_iterator = NamedDecl **;
   
   /// BasePaths - Construct a new BasePaths structure to record the
   /// paths for a derived-to-base search.
   explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true,
 bool DetectVirtual = true)
-  : Origin(), FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
-DetectVirtual(DetectVirtual), DetectedVirtual(nullptr),
-NumDeclsFound(0) {}
+  : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
+DetectVirtual(DetectVirtual) {}
 
   paths_iterator begin() { return Paths.begin(); }
   paths_iterator end()   { return Paths.end(); }
@@ -189,7 +192,8 @@ public:
   CXXBasePath&   front()   { return Paths.front(); }
   const CXXBasePath& front() const { return Paths.front(); }
   
-  typedef llvm::iterator_range decl_range;
+  using decl_range = llvm::iterator_range;
+
   decl_range found_decls();
   
   /// \brief Determine whether the path from the most-derived type to the
@@ -231,25 +235,24 @@ public:
 /// \brief Uniquely identifies a virtual method within a class
 /// hierarchy by the method itself and a class subobject number.
 struct UniqueVirtualMethod {
-  UniqueVirtualMethod()
-: Method(nullptr), Subobject(0), InVirtualSubobject(nullptr) { }
-
-  UniqueVir

r319489 - [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Nov 30 14:35:02 2017
New Revision: 319489

URL: http://llvm.org/viewvc/llvm-project?rev=319489&view=rev
Log:
[clang] Use add_llvm_install_targets

Use this function to create the install targets rather than doing so
manually, which gains us the `-stripped` install targets to perform
stripped installations.

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

Modified:
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/runtime/CMakeLists.txt
cfe/trunk/tools/c-index-test/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Thu Nov 30 14:35:02 2017
@@ -104,11 +104,9 @@ macro(add_clang_library name)
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@ macro(add_clang_tool name)
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -141,9 +141,7 @@ install(
   DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -101,12 +101,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} 
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P 
${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan 
ubsan ubsan-minimal)

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=319489&r1=319488&r2=319489&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Thu Nov 30 14:35:02 2017
@@ -56,10 +56,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CM

[PATCH] D40675: [clang] Use add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319489: [clang] Use add_llvm_install_targets (authored by 
smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D40675?vs=125013&id=125026#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40675

Files:
  cmake/modules/AddClang.cmake
  lib/Headers/CMakeLists.txt
  runtime/CMakeLists.txt
  tools/c-index-test/CMakeLists.txt
  tools/libclang/CMakeLists.txt

Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -141,9 +141,7 @@
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-clang-headers
-DEPENDS clang-headers
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=clang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-clang-headers
+   DEPENDS clang-headers
+   COMPONENT clang-headers)
 endif()
Index: tools/c-index-test/CMakeLists.txt
===
--- tools/c-index-test/CMakeLists.txt
+++ tools/c-index-test/CMakeLists.txt
@@ -56,10 +56,8 @@
 COMPONENT c-index-test)
 
   if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-add_custom_target(install-c-index-test
-  DEPENDS c-index-test
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=c-index-test
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-c-index-test
+ DEPENDS c-index-test
+ COMPONENT c-index-test)
   endif()
 endif()
Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -148,9 +148,6 @@
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
-  add_custom_target(install-libclang-headers
-DEPENDS
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=libclang-headers
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-libclang-headers
+   COMPONENT libclang-headers)
 endif()
Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -101,12 +101,9 @@
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
 COMPONENT compiler-rt)
 
-  add_custom_target(install-compiler-rt
-DEPENDS compiler-rt
-COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=compiler-rt
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-USES_TERMINAL)
+  add_llvm_install_targets(install-compiler-rt
+   DEPENDS compiler-rt
+   COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -104,11 +104,9 @@
 RUNTIME DESTINATION bin)
 
   if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
-add_custom_target(install-${name}
-  DEPENDS ${name}
-  COMMAND "${CMAKE_COMMAND}"
-  -DCMAKE_INSTALL_COMPONENT=${name}
-  -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
   endif()
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
@@ -147,11 +145,9 @@
   COMPONENT ${name})
 
 if(NOT CMAKE_CONFIGURATION_TYPES)
-  add_custom_target(install-${name}
-DEPENDS ${name}
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=${name}
--P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-${name}
+   DEPENDS ${name}
+   COMPONENT ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[PATCH] D40680: [libc++] Create install-stripped targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++, let's do it manually.


https://reviews.llvm.org/D40680

Files:
  include/CMakeLists.txt
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,14 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
+add_custom_target(install-libcxx-stripped DEPENDS install-cxx-stripped)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,9 +58,12 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
+add_custom_target(install-libcxx-headers-stripped DEPENDS 
install-libcxx-headers)
   endif()
 
 endif()


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,14 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
+add_custom_target(install-libcxx-stripped DEPENDS install-cxx-stripped)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,9 +58,12 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
+add_custom_target(install-libcxx-headers-stripped DEPENDS install-libcxx-headers)
   endif()
 
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40680: [libc++] Create install-stripped targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 125034.
smeenai added a comment.

Don't add deprecated target names, since clients should be switching over to 
the new ones.


https://reviews.llvm.org/D40680

Files:
  include/CMakeLists.txt
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,13 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,6 +58,8 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -389,5 +389,13 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx
   -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_custom_target(install-cxx-stripped
+  DEPENDS ${lib_install_target}
+  ${experimental_lib_install_target}
+  ${header_install_target}
+  COMMAND "${CMAKE_COMMAND}"
+  -DCMAKE_INSTALL_COMPONENT=cxx
+  -DCMAKE_INSTALL_DO_STRIP=1
+  -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
 add_custom_target(install-libcxx DEPENDS install-cxx)
 endif()
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -58,6 +58,8 @@
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=cxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+# Stripping is a no-op for headers
+add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
 
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40681: [libc++abi] Add install-cxxabi-stripped target

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++abi, let's do it manually.


https://reviews.llvm.org/D40681

Files:
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -192,6 +192,12 @@
 COMMAND "${CMAKE_COMMAND}"
 -DCMAKE_INSTALL_COMPONENT=cxxabi
 -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
+  add_custom_target(install-cxxabi-stripped
+DEPENDS cxxabi
+COMMAND "${CMAKE_COMMAND}"
+-DCMAKE_INSTALL_COMPONENT=cxxabi
+-DCMAKE_INSTALL_DO_STRIP=1
+-P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")
 
   # TODO: This is a legacy target name and should be removed at some point.
   add_custom_target(install-libcxxabi DEPENDS install-cxxabi)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

2017-11-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

r316380 added support for the 'simulator' environment to LLVM's triple. Clang's 
driver should pass this to the compiler when `-msimulator-version-min` 
option is specified so that the compiler can avoid using OS & arch specific 
checks.


Repository:
  rC Clang

https://reviews.llvm.org/D40682

Files:
  include/clang/Driver/ToolChain.h
  lib/CodeGen/CGObjCMac.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -41,7 +41,7 @@
 
 // RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
-// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0
+// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0-simulator
 
 // RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
@@ -85,13 +85,13 @@
 // CHECK-VERSION-TVOS83: "thumbv7-apple-tvos8.3.0"
 // RUN: %clang -target i386-apple-darwin -mtvos-simulator-version-min=8.3 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVSIM83 %s
-// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0"
+// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0-simulator"
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
 // CHECK-VERSION-WATCHOS20: "thumbv7k-apple-watchos2.0.0"
 // RUN: %clang -target i386-apple-darwin -mwatchos-simulator-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
-// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0"
+// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0-simulator"
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -987,6 +987,11 @@
 Builder.defineMacro("__nullable", "_Nullable");
   }
 
+  // Add a macro to differentiate between regular iOS/tvOS/watchOS targets and
+  // the corresponding simulator targets.
+  if (TI.getTriple().isOSDarwin() && TI.getTriple().isSimulatorEnvironment())
+Builder.defineMacro("__APPLE_EMBEDDED_SIMULATOR__", "1");
+
   // OpenMP definition
   // OpenMP 2.2:
   //   In implementations that support a preprocessor, the _OPENMP
Index: lib/Driver/ToolChains/Darwin.h
===
--- lib/Driver/ToolChains/Darwin.h
+++ lib/Driver/ToolChains/Darwin.h
@@ -317,7 +317,7 @@
   // FIXME: Eliminate these ...Target functions and derive separate tool chains
   // for these targets and put version in constructor.
   void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
- unsigned Micro) const {
+ unsigned Micro, bool Simulator) const {
 // FIXME: For now, allow reinitialization as long as values don't
 // change. This will go away when we move away from argument translation.
 if (TargetInitialized && TargetPlatform == Platform &&
@@ -328,6 +328,8 @@
 TargetInitialized = true;
 TargetPlatform = Platform;
 TargetVersion = VersionTuple(Major, Minor, Micro);
+if (Simulator)
+  const_cast(this)->setTripleEnvironment(llvm::Triple::Simulator);
   }
 
   bool isTargetIPhoneOS() const {
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1214,13 +1214,16 @@
   if (iOSVersion)
 ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args);
 
-  // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
-  // -m(iphone|tv|watch)simulator-version-min=X.Y.
+  bool Simulator;
+  // Differentiate between m(iphone|tv|watch)os-version-min=X.Y and
+  // -m(iphone|tv|watch)simulator-version-min=X.Y using the 'simulator'
+  // environment in the triple.
   if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
   Args.hasArg(options::OPT_mtvos_simulator_version_min_EQ) ||
   Args.hasArg(options::OPT_mwatchos_simulator_version_min_EQ))
-Args.append(Args.MakeSeparateArg(nullptr, Opts.getOption(options::OPT_D),
- " __APPLE_EMBEDDED_SIMULATOR__=1"));
+Simulator = true;
+  else
+Simulator = false;
 
   if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) {
 getDriver().Diag(diag::err_drv_argument_not_allowed_with)
@@ -1461,7 +1464,7 @@
  getTriple().getArch() == llvm::Tripl

[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-11-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Still worried about the effect on tools which parse clang diagnostics... please 
send a message to cfe-dev.  Hopefully we'll get responses there.


https://reviews.llvm.org/D33765



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


r319495 - Update website to mention that you still need -frelaxed-template-template-args to enable the corresponding C++17 feature in Clang 5.

2017-11-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov 30 15:07:29 2017
New Revision: 319495

URL: http://llvm.org/viewvc/llvm-project?rev=319495&view=rev
Log:
Update website to mention that you still need -frelaxed-template-template-args 
to enable the corresponding C++17 feature in Clang 5.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=319495&r1=319494&r2=319495&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Nov 30 15:07:29 2017
@@ -768,7 +768,8 @@ reverse construction order in that ABI.
 
 (12): Despite being the the resolution to a Defect Report, 
this
 feature is disabled by default in all language versions, and can be enabled
-explicitly with the flag -frelaxed-template-template-args in Clang 4.
+explicitly with the flag -frelaxed-template-template-args in Clang 4
+onwards.
 The change to the standard lacks a corresponding change for template partial
 ordering, resulting in ambiguity errors for reasonable and previously-valid
 code. This issue is expected to be rectified soon.


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


[PATCH] D40685: [libunwind] Switch to add_llvm_install_targets

2017-11-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
Herald added a subscriber: mgorny.

This gains us the install-unwind-stripped target, to perform stripping
during installation.


https://reviews.llvm.org/D40685

Files:
  src/CMakeLists.txt


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()


Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -139,9 +139,7 @@
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)
-  add_custom_target(install-unwind
-DEPENDS unwind
-COMMAND "${CMAKE_COMMAND}"
--DCMAKE_INSTALL_COMPONENT=unwind
--P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  add_llvm_install_targets(install-unwind
+   DEPENDS unwind
+   COMPONENT unwind)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >