r364724 - Various tweaks to MSVC natvis visualizers

2019-06-30 Thread Mike Spertus via cfe-commits
Author: mps
Date: Sun Jun 30 15:04:25 2019
New Revision: 364724

URL: http://llvm.org/viewvc/llvm-project?rev=364724=rev
Log:
Various tweaks to MSVC natvis visualizers

Make more consistent use of na format.
Improve visualization of deduction guides.
Add visualizer for explicit specifier (including conditionally explicit)
Fix some typos


Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=364724=364723=364724=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Sun Jun 30 15:04:25 2019
@@ -132,7 +132,7 @@ For later versions of Visual Studio, no
 
   
   
-{PointeeType, view(poly)} *
+{PointeeType, view(cpp)} *
 
   PointeeType
   *(clang::Type *)this, view(cmn)
@@ -209,7 +209,7 @@ For later versions of Visual Studio, no
 {(clang::TypeSourceInfo *)(MaybeModedTInfo.Value  
~7LL),view(cpp)na}
 {(clang::TypedefNameDecl::ModedTInfo 
*)(MaybeModedTInfo.Value  ~7LL),view(cpp)na}
 {(TypeDecl 
*)this,view(cpp)nand}
-typedef {this,view(type)na} 
{this,view(name)};
+typedef {this,view(type)na} 
{this,view(name)na};
 
   "Not yet calculated",sb
   (bool)(MaybeModedTInfo.Value  2)
@@ -219,6 +219,7 @@ For later versions of Visual Studio, no
 
   
   
+{(TypedefNameDecl 
*)this,view(name)nand}
 using {(TypedefNameDecl *)this,view(name)nand} = 
{(TypedefNameDecl *)this,view(type)nand}
   
 
@@ -575,27 +576,43 @@ For later versions of Visual Studio, no
IncludeView="cpp">{*(clang::detail::DeclarationNameExtra 
*)(Ptr  ~PtrMask),view(cpp)}
 {{Extra ({*(clang::detail::DeclarationNameExtra 
*)(Ptr  ~PtrMask)})}}
 
-  *(clang::IdentifierInfo *)(Ptr  ~PtrMask)
-  *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
-  *(clang::IdentifierInfo *)(Ptr  
~PtrMask)
-  *(clang::detail::CXXSpecialNameExtra *)(Ptr  
~PtrMask)
-  *(clang::detail::CXXSpecialNameExtra *)(Ptr  
~PtrMask)
-  *(clang::detail::CXXSpecialNameExtra *)(Ptr 
 ~PtrMask)
-  *(clang::detail::CXXOperatorIdName *)(Ptr  
~PtrMask)  
-  (clang::detail::DeclarationNameExtra *)(Ptr  
~PtrMask)
+  StoredNameKind(Ptr  PtrMask),en
+  *(clang::IdentifierInfo *)(Ptr  ~PtrMask),na
+  *(clang::IdentifierInfo *)(Ptr  
~PtrMask),na
+  *(clang::IdentifierInfo *)(Ptr  
~PtrMask),na
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr  
~PtrMask),na
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr  
~PtrMask),na
+  *(clang::detail::CXXSpecialNameExtra *)(Ptr 
 ~PtrMask),na
+  *(clang::detail::CXXOperatorIdName *)(Ptr  
~PtrMask),na  
+  (clang::detail::DeclarationNameExtra *)(Ptr  
~PtrMask),na
 
   
   
-{(NamedDecl *)(((CXXDeductionGuideNameExtra 
*)this)->Template),view(cpp)nand}
-C++ 
Deduction guide
+
+  {(CXXDeductionGuideNameExtra *)this,view(cpp)nand}
+
+
+  {(CXXDeductionGuideNameExtra *)this,nand}
+
 C++ Literal operator
 C++ 
Using directive  
 
{(clang::detail::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{"
  ",sb}{*this,view(cpp)}
+
+  (CXXDeductionGuideNameExtra *)this
+  ExtraKindOrNumArgs
+
+  
+  
+{Template->TemplatedDecl,view(cpp)}
+C++ Deduction guide for 
{Template->TemplatedDecl,view(cpp)}
   
   
 {Type,view(cpp)}
 {Type}
   
+  
+{Name}
+  
   
 {(clang::tok::TokenKind)Kind,en}
 {{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
@@ -640,9 +657,18 @@ For later versions of Visual Studio, no
   *(VarDecl*)this,nd
 
   
+  
+{"explicit 
",sb}
+
+explicit({ExplicitSpec,view(ptr)na})
+{ExplicitSpec,view(int)en}
+{ExplicitSpec,view(int)en} : 
{ExplicitSpec,view(ptr)na}
+  
   
-{Name,view(cpp)nd}({(FunctionDecl*)this,view(parm0)nd}) 
- {((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)DeclType.Value.Value)  
~15))-BaseType)->ResultType,view(cpp)}
+
{ExplicitSpec,view(cpp)}{Name,view(cpp)nd}({(FunctionDecl*)this,view(parm0)nand})
 - {((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)DeclType.Value.Value)  
~15))-BaseType)->ResultType,view(cpp)}
 
+  ExplicitSpec
+  (bool)FunctionDeclBits.IsCopyDeductionCandidate
   (FunctionDecl*)this,nd
 
   
@@ -724,7 +750,7 @@ For later versions of Visual Studio, no
 public
 protected
 private
-b
+
 {*(clang::NamedDecl 
*)(Ptr~Mask)}
 {*this,view(access)} {*this,view(decl)}
 


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


[PATCH] D63954: Add lifetime categories attributes

2019-06-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 2 inline comments as done.
mgehre added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4560-4561
+  if(AL.getKind() ==  ParsedAttr::AT_Owner) {
+if (checkAttrMutualExclusion(S, D, AL))
+  return;
+if (const auto *Attr = D->getAttr()) {

erik.pilkington wrote:
> This is duplicated with the first line in the function.
Removed the first line, which only checked for duplicate attributes on the same 
declaration, but we must check (here) that all matching
declaration are consistent - by performing all checks on the canonical 
declaration.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63954/new/

https://reviews.llvm.org/D63954



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


[PATCH] D63954: Add lifetime categories attributes

2019-06-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 207235.
mgehre added a comment.

Address some review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63954/new/

https://reviews.llvm.org/D63954

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/attr-gsl-owner-pointer.cpp

Index: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int [[gsl::Owner]] i;
+// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
+void [[gsl::Owner]] f();
+// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
+
+[[gsl::Owner]] void f();
+ // expected-warning@-1 {{'Owner' attribute only applies to classes}}
+
+struct S {
+};
+
+S [[gsl::Owner]] Instance;
+// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
+
+class [[gsl::Owner]] OwnerMissingParameter {};
+// expected-error@-1 {{'Owner' attribute takes one argument}}
+class [[gsl::Pointer]] PointerMissingParameter {};
+// expected-error@-1 {{'Pointer' attribute takes one argument}}
+
+class [[gsl::Owner(7)]] OwnerDerefNoType {};
+// expected-error@-1 {{expected a type}} expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
+
+class [[gsl::Pointer("int")]] PointerDerefNoType {};
+// expected-error@-1 {{expected a type}} expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
+
+class [[gsl::Owner(int)]] [[gsl::Pointer(int)]] BothOwnerPointer {};
+// expected-error@-1 {{'Pointer' and 'Owner' attributes are not compatible}}
+// expected-note@-2 {{conflicting attribute is here}}
+
+class [[gsl::Owner(int)]] [[gsl::Owner(int)]] DuplicateOwner {};
+
+class [[gsl::Pointer(int)]] [[gsl::Pointer(int)]] DuplicatePointer {};
+
+class [[gsl::Owner(void)]] OwnerVoidDerefType {};
+// expected-error@-1 {{'void' is an invalid argument to attribute 'Owner'}}
+class [[gsl::Pointer(void)]] PointerVoidDerefType {};
+// expected-error@-1 {{'void' is an invalid argument to attribute 'Pointer'}}
+
+class [[gsl::Owner(int)]] AnOwner {};
+class [[gsl::Pointer(S)]] APointer {};
+
+class AddOwnerLater {};
+class [[gsl::Owner(int)]] AddOwnerLater;
+
+class [[gsl::Pointer(int)]] AddConflictLater {};
+class [[gsl::Owner(int)]] AddConflictLater;
+// expected-error@-1 {{'Owner' and 'Pointer' attributes are not compatible}}
+// expected-note@-3 {{conflicting attribute is here}}
+
+class [[gsl::Owner(int)]] AddConflictLater2 {};
+class [[gsl::Owner(float)]] AddConflictLater2;
+// expected-error@-1 {{'Owner' and 'Owner' attributes are not compatible}}
+// expected-note@-3 {{conflicting attribute is here}}
+
+class [[gsl::Owner(int)]] AddTheSameLater {};
+class [[gsl::Owner(int)]] AddTheSameLater;
\ No newline at end of file
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -116,8 +116,10 @@
 // CHECK-NEXT: OpenCLNoSVM (SubjectMatchRule_variable)
 // CHECK-NEXT: OptimizeNone (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Overloadable (SubjectMatchRule_function)
+// CHECK-NEXT: Owner (SubjectMatchRule_record)
 // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
+// CHECK-NEXT: Pointer (SubjectMatchRule_record)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: RequireConstantInit (SubjectMatchRule_variable_is_global)
Index: clang/test/AST/ast-dump-attr.cpp
===
--- clang/test/AST/ast-dump-attr.cpp
+++ clang/test/AST/ast-dump-attr.cpp
@@ -211,6 +211,15 @@
 }
 }
 
+namespace TestLifetimeCategories {
+  class [[gsl::Owner(int)]] AOwner {};
+  // CHECK: CXXRecordDecl{{.*}} class AOwner
+  // CHECK: OwnerAttr {{.*}} int
+  class [[gsl::Pointer(int)]] APointer {};
+  // CHECK: CXXRecordDecl{{.*}} class APointer
+  // CHECK: PointerAttr {{.*}} int
+}
+
 // Verify the order of attributes in the Ast. It must reflect the order
 // in the parsed source.
 int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result));
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp

[PATCH] D63954: Add lifetime categories attributes

2019-06-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

We can and should explore both options and see what works best.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63954/new/

https://reviews.llvm.org/D63954



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


[PATCH] D62131: [ASTImporter] Remove NonEquivalentDecls from ASTImporter

2019-06-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

> The following happened: During the analysis we compared two Decls which 
> turned out to be inequivalent, so we cached them. Later during the analysis, 
> however, we added a new node to the redecl chain of one of these Decls which 
> we previously compared. Then another structural equivalent check followed for 
> the two Decls. And this time they should have been considered structurally 
> equivalent, but the cache already contained them as nonequivalent. This 
> resulted in a false positive NameConflict error.

Should we reset the non-equivalence relation after a decl is imported for this 
decl and its redecls?

> By this change the error had gone, and we did not recognize any analysis 
> slowdown. Remember, we still have a cache, but not a global cache in the 
> ASTImporter object.

Hm, I wonder if our cache is really useful or not. Unfortunately, I never did 
any measures.

Still the lack of a test disturbs me, even despite the fact that I got the idea.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62131/new/

https://reviews.llvm.org/D62131



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-06-30 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

For now, it isn't part of the debian packaging.
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/blob/snapshot/debian/rules#L563
it is removed as packaging phase as I have been told it isn't ready.

Anyway, the lib should not keep this name.
By definition, on linux, .so means shared. It should have a more explicit name.

@beanz Can you please rename it? thanks


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61909/new/

https://reviews.llvm.org/D61909



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


[PATCH] D63508: make -frewrite-includes also rewrite conditions in #if/#elif

2019-06-30 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 207229.
llunak added a comment.

Updated the patch again, commenting out just a part of #if didn't work either, 
so it seems there's no good way to comment out unwanted #if. This patch 
surrounds rewritten #if conditions by extra #if 0 #endif block to disable them, 
moreover it makes the conditions be part of an empty #if #endif block, so they 
do not break nesting.

I've also created https://reviews.llvm.org/D63979 to verify that the results in 
fact do compile.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63508/new/

https://reviews.llvm.org/D63508

Files:
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/test/Frontend/rewrite-includes-conditions.c
  clang/test/Frontend/rewrite-includes.c
  clang/test/Modules/preprocess-module.cpp

Index: clang/test/Modules/preprocess-module.cpp
===
--- clang/test/Modules/preprocess-module.cpp
+++ clang/test/Modules/preprocess-module.cpp
@@ -51,7 +51,7 @@
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DFILE_REWRITE -DINCLUDE -I%S/Inputs/preprocess
 //
 // Check that we can preprocess this user of the .pcm file.
-// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.pcm %s -I%t -E -frewrite-imports -o %t/preprocess-module.ii
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.pcm %s -I%t -E -frewrite-imports -DFILE_REWRITE_FULL -o %t/preprocess-module.ii
 // RUN: %clang_cc1 -fmodules %t/preprocess-module.ii -verify -fno-modules-error-recovery -DFILE_REWRITE_FULL
 //
 // Check that language / header search options are ignored when preprocessing from a .pcm file.
Index: clang/test/Frontend/rewrite-includes.c
===
--- clang/test/Frontend/rewrite-includes.c
+++ clang/test/Frontend/rewrite-includes.c
@@ -110,12 +110,27 @@
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h" 1{{$}}
-// CHECK-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
-// CHECK-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if __has_include_next(){{$}}
+// CHECK-NEXT: {{^}}#endif{{$}}
+// CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 0{{$}}
+// CHECK-NEXT: {{^}}#elif __has_include(){{$}}
+// CHECK-NEXT: {{^}}#endif{{$}}
+// CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#elif 0 /* evaluated by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
-// CHECK-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if !__has_include("rewrite-includes8.h"){{$}}
+// CHECK-NEXT: {{^}}#endif{{$}}
+// CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 5 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 6 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c" 2{{$}}
@@ -124,7 +139,12 @@
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h" 1{{$}}
-// CHECK-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if __has_include_next(){{$}}
+// CHECK-NEXT: {{^}}#endif{{$}}
+// CHECK-NEXT: {{^}}#endif /* disabled by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h"{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include_next {{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
@@ -193,15 +213,32 @@
 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECKNL-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECKNL-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
-// CHECKNL-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* disabled 

[PATCH] D63979: actually also compile output in tests for -frewrite-includes

2019-06-30 Thread Luboš Luňák via Phabricator via cfe-commits
llunak created this revision.
llunak added a project: clang.
Herald added a subscriber: cfe-commits.

This depends on https://reviews.llvm.org/D63508 (where I posted one version of 
a patch that created broken output without the tests catching it).


Repository:
  rC Clang

https://reviews.llvm.org/D63979

Files:
  clang/test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
  clang/test/Frontend/Inputs/rewrite-includes1.h
  clang/test/Frontend/Inputs/rewrite-includes2.h
  clang/test/Frontend/Inputs/rewrite-includes3.h
  clang/test/Frontend/Inputs/rewrite-includes4.h
  clang/test/Frontend/Inputs/rewrite-includes5.h
  clang/test/Frontend/Inputs/rewrite-includes6.h
  clang/test/Frontend/Inputs/rewrite-includes7.h
  clang/test/Frontend/rewrite-includes-cli-include.c
  clang/test/Frontend/rewrite-includes-conditions.c
  clang/test/Frontend/rewrite-includes.c

Index: clang/test/Frontend/rewrite-includes.c
===
--- clang/test/Frontend/rewrite-includes.c
+++ clang/test/Frontend/rewrite-includes.c
@@ -1,8 +1,9 @@
-// RUN: not %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -strict-whitespace %s
-// RUN: not %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
+// RUN: %clang_cc1 -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -E -frewrite-includes -P -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
+// RUN: %clang_cc1 -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | %clang_cc1 -Wall -Wextra -Wconversion -DFIRST -x c -fsyntax-only 2>&1 | FileCheck -check-prefix=COMPILE --implicit-check-not warning: %s
 // STARTCOMPARE
 #define A(a,b) a ## b
-A(1,2)
+A(in,t) a;
 #include "rewrite-includes1.h"
 #ifdef FIRST
 #define HEADER "rewrite-includes3.h"
@@ -21,94 +22,95 @@
 #include "rewrite-includes7.h"
 #include "rewrite-includes8.h"
 #include "rewrite-includes9.h"
+static int unused;
 // ENDCOMPARE
 // CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK: {{^}}// STARTCOMPARE{{$}}
 // CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}}
-// CHECK-NEXT: {{^}}A(1,2){{$}}
+// CHECK-NEXT: {{^}}A(in,t) a;{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECK-NEXT: {{^}}# 6 "{{.*}}rewrite-includes.c"{{$}}
+// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes1.h" 1{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#pragma clang system_header{{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes1.h" 3{{$}}
-// CHECK-NEXT: {{^}}included_line1{{$}}
+// CHECK-NEXT: {{^}}int included_line1;{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|)}}rewrite-includes1.h" 3{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes2.h" 1 3{{$}}
-// CHECK-NEXT: {{^}}included_line2{{$}}
+// CHECK-NEXT: {{^}}int included_line2;{{$}}
 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|)}}rewrite-includes1.h" 2 3{{$}}
-// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}}
+// CHECK-NEXT: {{^}}# 8 "{{.*}}rewrite-includes.c" 2{{$}}
 // CHECK-NEXT: {{^}}#ifdef FIRST{{$}}
 // CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include HEADER{{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECK-NEXT: {{^}}# 9 "{{.*}}rewrite-includes.c"{{$}}
+// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes3.h" 1{{$}}
-// CHECK-NEXT: {{^}}included_line3{{$}}
-// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}}
+// CHECK-NEXT: {{^}}unsigned int included_line3 = -10;{{$}}
+// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c" 2{{$}}
 // CHECK-NEXT: {{^}}#else{{$}}
-// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c"{{$}}
+// CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECK-NEXT: {{^}}# 11 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}}
-// CHECK-NEXT: 

[PATCH] D63977: [NFC][clang] Adding ability to skip compiler phases in clang driver.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 207228.
plotfi added a comment.

Removing obvious comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63977/new/

https://reviews.llvm.org/D63977

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Phases.h
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  llvm::SmallSet SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, SkipPhases };
 }
 
 static Arg *MakeInputArg(DerivedArgList , OptTable ,
@@ -3148,7 +3149,8 @@
   }
 
   Arg *FinalPhaseArg;
-  phases::ID FinalPhase = getFinalPhase(Args, );
+  phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, );
+  phases::ID FinalPhase = PhasesToRun.FinalPhase;
 
   if (FinalPhase == phases::Link) {
 if (Args.hasArg(options::OPT_emit_llvm))
@@ -3307,6 +3309,9 @@
   if (Phase > FinalPhase)
 break;
 
+  if (llvm::is_contained(PhasesToRun.SkipPhases, Phase))
+continue;
+
   // Add any offload action the host action depends on.
   Current = OffloadBuilder.addDeviceDependencesToHostAction(
   Current, InputArg, Phase, FinalPhase, PL);
Index: clang/include/clang/Driver/Phases.h
===
--- clang/include/clang/Driver/Phases.h
+++ clang/include/clang/Driver/Phases.h
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include 
+
 #ifndef LLVM_CLANG_DRIVER_PHASES_H
 #define LLVM_CLANG_DRIVER_PHASES_H
 
@@ -23,6 +25,11 @@
 Link
   };
 
+  struct PhasesToRun {
+ID FinalPhase;
+llvm::SmallSet SkipPhases;
+  };
+
   enum {
 MaxNumberOfPhases = Link + 1
   };
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -251,10 +251,11 @@
   llvm::opt::DerivedArgList *
   TranslateInputArgs(const llvm::opt::InputArgList ) const;
 
-  // getFinalPhase - Determine which compilation mode we are in and record
-  // which option we used to determine the final phase.
-  phases::ID getFinalPhase(const llvm::opt::DerivedArgList ,
-   llvm::opt::Arg **FinalPhaseArg = nullptr) const;
+  // getPhasesToRun - Determine which compilation mode we are in and record
+  // which option we used to determine the final phase and the phases to skip.
+  phases::PhasesToRun
+  getPhasesToRun(const llvm::opt::DerivedArgList ,
+ llvm::opt::Arg **FinalPhaseArg = nullptr) const;
 
   // Before executing jobs, sets up response files for commands that need them.
   void setUpResponseFiles(Compilation , Command );


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  llvm::SmallSet SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, SkipPhases };
 }
 
 static Arg *MakeInputArg(DerivedArgList , OptTable ,
@@ -3148,7 +3149,8 @@
   }
 
   Arg *FinalPhaseArg;
-  phases::ID FinalPhase = getFinalPhase(Args, );
+  phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, );
+  phases::ID FinalPhase = PhasesToRun.FinalPhase;
 
   if (FinalPhase == phases::Link) {
 if (Args.hasArg(options::OPT_emit_llvm))
@@ -3307,6 +3309,9 @@
   if (Phase > FinalPhase)
   

[PATCH] D63977: [NFC][clang] Adding ability to skip compiler phases in clang driver.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 207227.
plotfi added a comment.

Add full context, change std::set to llvm::SmallSet


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63977/new/

https://reviews.llvm.org/D63977

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Phases.h
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  llvm::SmallSet SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, SkipPhases };
 }
 
 static Arg *MakeInputArg(DerivedArgList , OptTable ,
@@ -3148,7 +3149,8 @@
   }
 
   Arg *FinalPhaseArg;
-  phases::ID FinalPhase = getFinalPhase(Args, );
+  phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, );
+  phases::ID FinalPhase = PhasesToRun.FinalPhase;
 
   if (FinalPhase == phases::Link) {
 if (Args.hasArg(options::OPT_emit_llvm))
@@ -3307,6 +3309,10 @@
   if (Phase > FinalPhase)
 break;
 
+  // If we find Phase in the SkipPhases, then skip it.
+  if (llvm::is_contained(PhasesToRun.SkipPhases, Phase))
+continue;
+
   // Add any offload action the host action depends on.
   Current = OffloadBuilder.addDeviceDependencesToHostAction(
   Current, InputArg, Phase, FinalPhase, PL);
Index: clang/include/clang/Driver/Phases.h
===
--- clang/include/clang/Driver/Phases.h
+++ clang/include/clang/Driver/Phases.h
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include 
+
 #ifndef LLVM_CLANG_DRIVER_PHASES_H
 #define LLVM_CLANG_DRIVER_PHASES_H
 
@@ -23,6 +25,11 @@
 Link
   };
 
+  struct PhasesToRun {
+ID FinalPhase;
+llvm::SmallSet SkipPhases;
+  };
+
   enum {
 MaxNumberOfPhases = Link + 1
   };
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -251,10 +251,11 @@
   llvm::opt::DerivedArgList *
   TranslateInputArgs(const llvm::opt::InputArgList ) const;
 
-  // getFinalPhase - Determine which compilation mode we are in and record
-  // which option we used to determine the final phase.
-  phases::ID getFinalPhase(const llvm::opt::DerivedArgList ,
-   llvm::opt::Arg **FinalPhaseArg = nullptr) const;
+  // getPhasesToRun - Determine which compilation mode we are in and record
+  // which option we used to determine the final phase and the phases to skip.
+  phases::PhasesToRun
+  getPhasesToRun(const llvm::opt::DerivedArgList ,
+ llvm::opt::Arg **FinalPhaseArg = nullptr) const;
 
   // Before executing jobs, sets up response files for commands that need them.
   void setUpResponseFiles(Compilation , Command );


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  llvm::SmallSet SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, SkipPhases };
 }
 
 static Arg *MakeInputArg(DerivedArgList , OptTable ,
@@ -3148,7 +3149,8 @@
   }
 
   Arg *FinalPhaseArg;
-  phases::ID FinalPhase = getFinalPhase(Args, );
+  phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, );
+  phases::ID FinalPhase = PhasesToRun.FinalPhase;
 
   if (FinalPhase == phases::Link) {
 if 

[PATCH] D62329: [ASTImporter] Structural eq: handle DependentScopeDeclRefExpr

2019-06-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fixes!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62329/new/

https://reviews.llvm.org/D62329



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


[PATCH] D63977: [NFC][clang] Adding ability to skip compiler phases in clang driver.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/include/clang/Driver/Phases.h:30
+ID FinalPhase;
+std::set SkipPhases;
+  };

I could change this to a SmallVector or SmallSet 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63977/new/

https://reviews.llvm.org/D63977



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


[PATCH] D63978: Very early work on interface stub merger plumbing.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 207224.
plotfi added a comment.

had some accidentally not-removed stray print output and/or expletives, 
apologies.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63978/new/

https://reviews.llvm.org/D63978

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -45,6 +45,21 @@
   : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
 };
 
+namespace ifstool {
+class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool {
+public:
+  Merger(const ToolChain ) : GnuTool("IFS::Merger", "merger", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace ifstool
+
 /// Directly call GNU Binutils' assembler and linker.
 namespace gnutools {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -341,6 +341,21 @@
   !Args.hasArg(options::OPT_static_pie);
 }
 
+void tools::ifstool::Merger::ConstructJob(Compilation , const JobAction ,
+  const InputInfo ,
+  const InputInfoList ,
+  const ArgList ,
+  const char *LinkingOutput) const {
+  llvm::errs() << "Construct merger job\n";
+  SmallVector CmdArgs;
+  const char *Exec = "/path/to/llvm-ifs";
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+  for (auto Input : Inputs)
+CmdArgs.push_back(Input.getFilename());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+}
+
 void tools::gnutools::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,7 +286,6 @@
  (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
  (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
- (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) ||
  (PhaseArg = DAL.getLastArg(options::OPT__analyze,
 options::OPT__analyze_auto)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
@@ -301,6 +300,10 @@
 FinalPhase = phases::Assemble;
 
 // Otherwise do everything.
+  } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs))) {
+FinalPhase = phases::Link;
+SkipPhases.insert(phases::Backend);
+SkipPhases.insert(phases::Assemble);
   } else
 FinalPhase = phases::Link;
 
@@ -3900,6 +3903,9 @@
   T = combineAssembleBackend(ActionChain, Inputs, CollapsedOffloadAction);
 if (!T)
   T = combineBackendCompile(ActionChain, Inputs, CollapsedOffloadAction);
+if (!T && C.getArgs().getLastArg(options::OPT_emit_iterface_stubs) &&
+isa(BaseAction))
+  T = new tools::ifstool::Merger(TC);
 if (!T) {
   Inputs = BaseAction->getInputs();
   T = TC.SelectTool(*BaseAction);


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -45,6 +45,21 @@
   : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
 };
 
+namespace ifstool {
+class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool {
+public:
+  Merger(const ToolChain ) : GnuTool("IFS::Merger", "merger", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace ifstool
+
 /// Directly call GNU Binutils' assembler and linker.
 namespace gnutools {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: clang/lib/Driver/ToolChains/Gnu.cpp

[PATCH] D63978: Very early work on interface stub merger plumbing.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added a reviewer: compnerd.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is really early.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63978

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -45,6 +45,21 @@
   : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
 };
 
+namespace ifstool {
+class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool {
+public:
+  Merger(const ToolChain ) : GnuTool("IFS::Merger", "merger", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace ifstool
+
 /// Directly call GNU Binutils' assembler and linker.
 namespace gnutools {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -341,6 +341,21 @@
   !Args.hasArg(options::OPT_static_pie);
 }
 
+void tools::ifstool::Merger::ConstructJob(Compilation , const JobAction ,
+  const InputInfo ,
+  const InputInfoList ,
+  const ArgList ,
+  const char *LinkingOutput) const {
+  llvm::errs() << "Construct merger job\n";
+  SmallVector CmdArgs;
+  const char *Exec = "/path/to/llvm-ifs";
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+  for (auto Input : Inputs)
+CmdArgs.push_back(Input.getFilename());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+}
+
 void tools::gnutools::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,7 +286,6 @@
  (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
  (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
- (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) ||
  (PhaseArg = DAL.getLastArg(options::OPT__analyze,
 options::OPT__analyze_auto)) ||
  (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
@@ -301,6 +300,10 @@
 FinalPhase = phases::Assemble;
 
 // Otherwise do everything.
+  } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs))) {
+FinalPhase = phases::Link;
+SkipPhases.insert(phases::Backend);
+SkipPhases.insert(phases::Assemble);
   } else
 FinalPhase = phases::Link;
 
@@ -3312,6 +3315,7 @@
   // If we find Phase in the SkipPhases, then skip it.
   if (PhasesToRun.SkipPhases.find(Phase) != PhasesToRun.SkipPhases.end())
 continue;
+  llvm::errs() << "PHASE: " << Phase << "\n";
 
   // Add any offload action the host action depends on.
   Current = OffloadBuilder.addDeviceDependencesToHostAction(
@@ -3900,6 +3904,11 @@
   T = combineAssembleBackend(ActionChain, Inputs, CollapsedOffloadAction);
 if (!T)
   T = combineBackendCompile(ActionChain, Inputs, CollapsedOffloadAction);
+if (!T && C.getArgs().getLastArg(options::OPT_emit_iterface_stubs) &&
+isa(BaseAction)) {
+  llvm::errs() << "WTF\n";
+  T = new tools::ifstool::Merger(TC);
+}
 if (!T) {
   Inputs = BaseAction->getInputs();
   T = TC.SelectTool(*BaseAction);


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -45,6 +45,21 @@
   : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
 };
 
+namespace ifstool {
+class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool {
+public:
+  Merger(const ToolChain ) : GnuTool("IFS::Merger", "merger", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+

[PATCH] D63977: [NFC][clang] Adding ability to skip compiler phases in clang driver.

2019-06-30 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changing getFinalPhase to getPhasesToRun. Instead of only returning the final 
phase it returns the final phase as well as a collection of the phases to skip. 
This is useful for cases where you want to do up to a compile phase that emits 
some information per compilation unit, but then you want a link phase for 
merging the compilation unit artifacts into one file without having to invoke 
the backend/assembler phases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63977

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Phases.h
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  std::set SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, SkipPhases };
 }
 
 static Arg *MakeInputArg(DerivedArgList , OptTable ,
@@ -3148,7 +3149,8 @@
   }
 
   Arg *FinalPhaseArg;
-  phases::ID FinalPhase = getFinalPhase(Args, );
+  phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, );
+  phases::ID FinalPhase = PhasesToRun.FinalPhase;
 
   if (FinalPhase == phases::Link) {
 if (Args.hasArg(options::OPT_emit_llvm))
@@ -3307,6 +3309,10 @@
   if (Phase > FinalPhase)
 break;
 
+  // If we find Phase in the SkipPhases, then skip it.
+  if (PhasesToRun.SkipPhases.find(Phase) != PhasesToRun.SkipPhases.end())
+continue;
+
   // Add any offload action the host action depends on.
   Current = OffloadBuilder.addDeviceDependencesToHostAction(
   Current, InputArg, Phase, FinalPhase, PL);
Index: clang/include/clang/Driver/Phases.h
===
--- clang/include/clang/Driver/Phases.h
+++ clang/include/clang/Driver/Phases.h
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include 
+
 #ifndef LLVM_CLANG_DRIVER_PHASES_H
 #define LLVM_CLANG_DRIVER_PHASES_H
 
@@ -23,6 +25,11 @@
 Link
   };
 
+  struct PhasesToRun {
+ID FinalPhase;
+std::set SkipPhases;
+  };
+
   enum {
 MaxNumberOfPhases = Link + 1
   };
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -251,10 +251,11 @@
   llvm::opt::DerivedArgList *
   TranslateInputArgs(const llvm::opt::InputArgList ) const;
 
-  // getFinalPhase - Determine which compilation mode we are in and record
-  // which option we used to determine the final phase.
-  phases::ID getFinalPhase(const llvm::opt::DerivedArgList ,
-   llvm::opt::Arg **FinalPhaseArg = nullptr) const;
+  // getPhasesToRun - Determine which compilation mode we are in and record
+  // which option we used to determine the final phase and the phases to skip.
+  phases::PhasesToRun
+  getPhasesToRun(const llvm::opt::DerivedArgList ,
+ llvm::opt::Arg **FinalPhaseArg = nullptr) const;
 
   // Before executing jobs, sets up response files for commands that need them.
   void setUpResponseFiles(Compilation , Command );


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
 // Determine which compilation mode we are in. We look for options which
 // affect the phase, starting with the earliest phases, and record which
 // option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList ,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList ,
+   Arg **FinalPhaseArg) const {
   Arg *PhaseArg = nullptr;
   phases::ID FinalPhase;
+  std::set SkipPhases;
 
   // -{E,EP,P,M,MM} only run the preprocessor.
   if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
   if (FinalPhaseArg)
 *FinalPhaseArg = PhaseArg;
 
-  return FinalPhase;
+  return { FinalPhase, 

[PATCH] D63603: [ASTImporter] Propagate error from ImportDeclContext

2019-06-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Hi Gabor,
The patch looks good. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63603/new/

https://reviews.llvm.org/D63603



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


[PATCH] D63508: make -frewrite-includes also rewrite conditions in #if/#elif

2019-06-30 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 207220.
llunak added a comment.

Updated patch, removed ()'s around 1/0, fixed to use CommentOutDirective().


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63508/new/

https://reviews.llvm.org/D63508

Files:
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/test/Frontend/rewrite-includes-conditions.c
  clang/test/Frontend/rewrite-includes.c
  clang/test/Modules/preprocess-module.cpp

Index: clang/test/Modules/preprocess-module.cpp
===
--- clang/test/Modules/preprocess-module.cpp
+++ clang/test/Modules/preprocess-module.cpp
@@ -51,7 +51,7 @@
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DFILE_REWRITE -DINCLUDE -I%S/Inputs/preprocess
 //
 // Check that we can preprocess this user of the .pcm file.
-// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.pcm %s -I%t -E -frewrite-imports -o %t/preprocess-module.ii
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.pcm %s -I%t -E -frewrite-imports -DFILE_REWRITE_FULL -o %t/preprocess-module.ii
 // RUN: %clang_cc1 -fmodules %t/preprocess-module.ii -verify -fno-modules-error-recovery -DFILE_REWRITE_FULL
 //
 // Check that language / header search options are ignored when preprocessing from a .pcm file.
Index: clang/test/Frontend/rewrite-includes.c
===
--- clang/test/Frontend/rewrite-includes.c
+++ clang/test/Frontend/rewrite-includes.c
@@ -110,12 +110,23 @@
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h" 1{{$}}
-// CHECK-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
-// CHECK-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#/*if*/ __has_include_next(){{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#/*elif*/ __has_include(){{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#elif 0 /* evaluated by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
-// CHECK-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#/*if*/ !__has_include("rewrite-includes8.h"){{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 5 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 6 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c" 2{{$}}
@@ -124,7 +135,11 @@
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h" 1{{$}}
-// CHECK-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#/*if*/ __has_include_next(){{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h"{{$}}
 // CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}#include_next {{$}}
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
@@ -193,15 +208,27 @@
 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECKNL-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECKNL-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
-// CHECKNL-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#/*if*/ __has_include_next(){{$}}
+// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#/*elif*/ __has_include(){{$}}
+// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#elif 0 /* evaluated by -frewrite-includes */{{$}}
 // 

[PATCH] D63508: make -frewrite-includes also rewrite conditions in #if/#elif

2019-06-30 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

In D63508#1558390 , @rsmith wrote:

> Patch generally looks good; just a minor concern about the output format.




> Also, we don't need parentheses around the constant 0 or 1.

That was consistent with what the current code does, but I don't mind changing 
that.

> Adding an extra line here is going to mess up presumed line numbering.

That's ok. The code already inserts extra lines and always fixes them up using 
line markers. And I think that's unavoidable due to reasons below.

> Perhaps instead we could prepend a #if 0 /* or #if 1 /* to the directive:

That's fragile. Do it with something like "#if value /*blah*/ " and you'll have 
a problem with comment nesting. That is why all the changes are inserted 
between the two extra #if 0 / #endif lines. IIRC I thought about this for a 
while when designing -frewrite-includes and this is the best I came up with.
But you made me realize that the previous patch didn't handle this properly, so 
the current one has been fixed to be consistent there.

> I don't think we really need the "evaluated by -frewrite-includes" part, but 
> I have no objection to including it.

It's strictly speaking not necessary, but it's there to make it easier to 
identify those extra #if lines added by -frewrite-includes.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63508/new/

https://reviews.llvm.org/D63508



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-06-30 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

@sylvestre.ledru @beanz  After this change, the Debian packaging on 
apt.llvm.org is basically broken. See 
https://bugs.llvm.org/show_bug.cgi?id=42432. I'm sure this can be fixed in 
packaging, but I don't know enough about it to know exactly what to do. At any 
rate I think the idea that `libclang_shared.so.*` can stay out of the published 
package is wrong. At least unless there's also a way to build the Clang tree 
withouth the `clang_shared` target.

Would be grateful for any ideas on how to fix this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61909/new/

https://reviews.llvm.org/D61909



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


[PATCH] D62376: [ASTImporter] Mark erroneous nodes in shared st

2019-06-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Thanks for the explanation!
It will be good if someone else takes a look at this patch.




Comment at: clang/include/clang/AST/ASTImporterSharedState.h:40
+  /// never cleared (like ImportedFromDecls).
+  llvm::DenseMap ImportErrors;
+

ErrorsInToContext?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62376/new/

https://reviews.llvm.org/D62376



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


[clang-tools-extra] r364720 - Cleanup: llvm::bsearch -> llvm::partition_point after r364719

2019-06-30 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sun Jun 30 04:19:56 2019
New Revision: 364720

URL: http://llvm.org/viewvc/llvm-project?rev=364720=rev
Log:
Cleanup: llvm::bsearch -> llvm::partition_point after r364719

Modified:
clang-tools-extra/trunk/clangd/index/Symbol.cpp

Modified: clang-tools-extra/trunk/clangd/index/Symbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Symbol.cpp?rev=364720=364719=364720=diff
==
--- clang-tools-extra/trunk/clangd/index/Symbol.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Symbol.cpp Sun Jun 30 04:19:56 2019
@@ -35,8 +35,8 @@ float quality(const Symbol ) {
 }
 
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID ) const {
-  auto It =
-  llvm::bsearch(Symbols, [&](const Symbol ) { return !(S.ID < ID); });
+  auto It = llvm::partition_point(Symbols,
+  [&](const Symbol ) { return S.ID < ID; });
   if (It != Symbols.end() && It->ID == ID)
 return It;
   return Symbols.end();


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


r364720 - Cleanup: llvm::bsearch -> llvm::partition_point after r364719

2019-06-30 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sun Jun 30 04:19:56 2019
New Revision: 364720

URL: http://llvm.org/viewvc/llvm-project?rev=364720=rev
Log:
Cleanup: llvm::bsearch -> llvm::partition_point after r364719

Modified:
cfe/trunk/lib/Tooling/Syntax/Tokens.cpp

Modified: cfe/trunk/lib/Tooling/Syntax/Tokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Syntax/Tokens.cpp?rev=364720=364719=364720=diff
==
--- cfe/trunk/lib/Tooling/Syntax/Tokens.cpp (original)
+++ cfe/trunk/lib/Tooling/Syntax/Tokens.cpp Sun Jun 30 04:19:56 2019
@@ -127,8 +127,8 @@ TokenBuffer::spelledForExpandedToken(con
 
   unsigned ExpandedIndex = Expanded - ExpandedTokens.data();
   // Find the first mapping that produced tokens after \p Expanded.
-  auto It = llvm::bsearch(File.Mappings, [&](const Mapping ) {
-return ExpandedIndex < M.BeginExpanded;
+  auto It = llvm::partition_point(File.Mappings, [&](const Mapping ) {
+return M.BeginExpanded <= ExpandedIndex;
   });
   // Our token could only be produced by the previous mapping.
   if (It == File.Mappings.begin()) {
@@ -212,8 +212,8 @@ TokenBuffer::expansionStartingAt(const s
  Spelled < (File.SpelledTokens.data() + File.SpelledTokens.size()));
 
   unsigned SpelledIndex = Spelled - File.SpelledTokens.data();
-  auto M = llvm::bsearch(File.Mappings, [&](const Mapping ) {
-return SpelledIndex <= M.BeginSpelled;
+  auto M = llvm::partition_point(File.Mappings, [&](const Mapping ) {
+return M.BeginSpelled < SpelledIndex;
   });
   if (M == File.Mappings.end() || M->BeginSpelled != SpelledIndex)
 return llvm::None;


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


[PATCH] D63718: [ADT] Implement llvm::bsearch() with std::partition_point()

2019-06-30 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364719: [ADT] Implement llvm::bsearch() with 
std::partition_point() (authored by MaskRay, committed by ).
Herald added subscribers: kristina, ilya-biryukov.

Changed prior to commit:
  https://reviews.llvm.org/D63718?vs=206220=207218#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63718/new/

https://reviews.llvm.org/D63718

Files:
  clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
  llvm/trunk/include/llvm/ADT/STLExtras.h
  llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
  llvm/trunk/unittests/ADT/STLExtrasTest.cpp

Index: llvm/trunk/unittests/ADT/STLExtrasTest.cpp
===
--- llvm/trunk/unittests/ADT/STLExtrasTest.cpp
+++ llvm/trunk/unittests/ADT/STLExtrasTest.cpp
@@ -470,19 +470,7 @@
 }
 
 TEST(STLExtrasTest, bsearch) {
-  // Integer version.
-  EXPECT_EQ(7u, bsearch(5, 10, [](unsigned X) { return X >= 7; }));
-  EXPECT_EQ(5u, bsearch(5, 10, [](unsigned X) { return X >= 1; }));
-  EXPECT_EQ(10u, bsearch(5, 10, [](unsigned X) { return X >= 50; }));
-
-  // Iterator version.
   std::vector V = {1, 3, 5, 7, 9};
-  EXPECT_EQ(V.begin() + 3,
-bsearch(V.begin(), V.end(), [](unsigned X) { return X >= 7; }));
-  EXPECT_EQ(V.begin(),
-bsearch(V.begin(), V.end(), [](unsigned X) { return X >= 1; }));
-  EXPECT_EQ(V.end(),
-bsearch(V.begin(), V.end(), [](unsigned X) { return X >= 50; }));
 
   // Range version.
   EXPECT_EQ(V.begin() + 3, bsearch(V, [](unsigned X) { return X >= 7; }));
Index: llvm/trunk/include/llvm/ADT/STLExtras.h
===
--- llvm/trunk/include/llvm/ADT/STLExtras.h
+++ llvm/trunk/include/llvm/ADT/STLExtras.h
@@ -1322,44 +1322,13 @@
   std::stable_sort(adl_begin(Range), adl_end(Range), C);
 }
 
-/// Binary search for the first index where a predicate is true.
-/// Returns the first I in [Lo, Hi) where C(I) is true, or Hi if it never is.
-/// Requires that C is always false below some limit, and always true above it.
-///
-/// Example:
-///   size_t DawnModernEra = bsearch(1776, 2050, [](size_t Year){
-/// return Presidents.for(Year).twitterHandle() != None;
-///   });
-///
-/// Note the return value differs from std::binary_search!
-template 
-size_t bsearch(size_t Lo, size_t Hi, Predicate P) {
-  while (Lo != Hi) {
-assert(Hi > Lo);
-size_t Mid = Lo + (Hi - Lo) / 2;
-if (P(Mid))
-  Hi = Mid;
-else
-  Lo = Mid + 1;
-  }
-  return Hi;
-}
-
-/// Binary search for the first iterator where a predicate is true.
-/// Returns the first I in [Lo, Hi) where C(*I) is true, or Hi if it never is.
-/// Requires that C is always false below some limit, and always true above it.
-template ())>
-It bsearch(It Lo, It Hi, Predicate P) {
-  return std::lower_bound(Lo, Hi, 0u,
-  [&](const Val , unsigned) { return !P(V); });
-}
-
 /// Binary search for the first iterator in a range where a predicate is true.
 /// Requires that C is always false below some limit, and always true above it.
-template 
+template ()))>
 auto bsearch(R &, Predicate P) -> decltype(adl_begin(Range)) {
-  return bsearch(adl_begin(Range), adl_end(Range), P);
+  return std::partition_point(adl_begin(Range), adl_end(Range),
+  [&](const Val ) { return !P(V); });
 }
 
 /// Wrapper function around std::equal to detect if all elements
Index: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
===
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
@@ -492,8 +492,9 @@
 /// Move iterator to the next IdxMBBPair where the SlotIndex is greater or
 /// equal to \p To.
 MBBIndexIterator advanceMBBIndex(MBBIndexIterator I, SlotIndex To) const {
-  return llvm::bsearch(I, idx2MBBMap.end(),
-   [=](const IdxMBBPair ) { return To <= IM.first; });
+  return std::partition_point(
+  I, idx2MBBMap.end(),
+  [=](const IdxMBBPair ) { return IM.first < To; });
 }
 
 /// Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex
Index: clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
@@ -50,8 +50,8 @@
   return;
 advanceToChunk(ID);
 // Try to find ID within current chunk.
-CurrentID = llvm::bsearch(CurrentID, DecompressedChunk.end(),
-  [&](const DocID D) { return D >= ID; });
+CurrentID = std::partition_point(CurrentID, DecompressedChunk.end(),
+ [&](const DocID D) { return D < ID; });
 normalizeCursor();
   }
 
@@ -103,8 +103,8 @@
 if 

[clang-tools-extra] r364719 - [ADT] Implement llvm::bsearch() with std::partition_point()

2019-06-30 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Sun Jun 30 02:17:59 2019
New Revision: 364719

URL: http://llvm.org/viewvc/llvm-project?rev=364719=rev
Log:
[ADT] Implement llvm::bsearch() with std::partition_point()

Summary:
Delete the begin-end form because the standard std::partition_point
can be easily used as a replacement.

The ranges-style llvm::bsearch will be renamed to llvm::partition_point
in the next clean-up patch.

The name "bsearch" doesn't meet people's expectation because in C:

> If two or more members compare equal, which member is returned is unspecified.

Reviewed By: sammccall

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp?rev=364719=364718=364719=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/PostingList.cpp Sun Jun 30 
02:17:59 2019
@@ -50,8 +50,8 @@ public:
   return;
 advanceToChunk(ID);
 // Try to find ID within current chunk.
-CurrentID = llvm::bsearch(CurrentID, DecompressedChunk.end(),
-  [&](const DocID D) { return D >= ID; });
+CurrentID = std::partition_point(CurrentID, DecompressedChunk.end(),
+ [&](const DocID D) { return D < ID; });
 normalizeCursor();
   }
 
@@ -103,8 +103,8 @@ private:
 if ((CurrentChunk != Chunks.end() - 1) &&
 ((CurrentChunk + 1)->Head <= ID)) {
   CurrentChunk =
-  llvm::bsearch(CurrentChunk + 1, Chunks.end(),
-[&](const Chunk ) { return C.Head >= ID; });
+  std::partition_point(CurrentChunk + 1, Chunks.end(),
+   [&](const Chunk ) { return C.Head < ID; });
   --CurrentChunk;
   DecompressedChunk = CurrentChunk->decompress();
   CurrentID = DecompressedChunk.begin();


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


[PATCH] D62375: [ASTImporter] Mark erroneous nodes in from ctx

2019-06-30 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hello Gabor,
Thank you for the explanation. I got the idea of this patch anyway, but it will 
be definitely useful for anyone digging into the code. Should we make it a 
comment for ImportPathTy?




Comment at: clang/lib/AST/ASTImporter.cpp:8682
+
+void ASTImporter::ImportPathTy::push(Decl *D) {
+  Nodes.push_back(D);

I think these definitions are small enough to move them into the class 
definitions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62375/new/

https://reviews.llvm.org/D62375



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


[PATCH] D63718: [ADT] Implement llvm::bsearch() with std::partition_point()

2019-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Funny, the int version was the original motivation and now seems totally 
unused. And apparently none of us know the standard library very well.
Thanks for cleaning this up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63718/new/

https://reviews.llvm.org/D63718



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