[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-07-07 Thread Milian Wolff via Phabricator via cfe-commits
milianw abandoned this revision.
milianw added a comment.

great, thanks for the help - please land the other change then


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-07-03 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

@jkorous ping? can you chime in on either of the two patches? I'm fine with 
either, and D82629  comes with a test too. So 
maybe let's just go with that one? If so, could you integrate that one please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-07-01 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

@jkorous how would you use a debugger (would be GDB for me) to find the source 
- I would have to use RR or something like that to see why and where the 
invalid node is added, no?

I also don't have the breaking code at hand anymore, I can try to come up with 
a way to reproduce it, but as I said it was very non-intuitive and in a large 
file. I think it was related to parse errors in a statement for a variable that 
was then captured in a lambda - but that's just a hunch I got from the 
backtrace so far.

Generally, it's not very straight forward to build a reduced crash test for 
clang-c. Maybe one could use c-reduce with a minimal visitor... And preprocess 
the file to have it standalone. I'll see if I get a chance to look into this 
any time soon, I doubt it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-07-01 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

Also see https://reviews.llvm.org/D82629 which I believe is also a fix for this 
crash. But I didn't use a VLA in my code, but maybe the parse error just 
triggered something similar like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82629: [libclang] Fix crash when visiting a captured VLA.

2020-07-01 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

this relates to https://reviews.llvm.org/D82740 too, but comes with a test 
which is good. personally I would place the check directly within Visit to make 
it more generically prevent a crash on invalid input, but that's probably a 
subjective design decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82629



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-29 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

I'm not sure how to write a unit test for this, but I ran into a reproducible 
crash with a complex C++ file which got fixed by this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-29 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
milianw added reviewers: bkramer, yvvan, nik.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Fixes crash when visiting a partial AST after encountering
a parse error in the input code:

  #5  clang::Stmt::getStmtClass (this=) at 
llvm-project/clang/include/clang/AST/Stmt.h:1125
  #6  clang::cxcursor::MakeCXCursor (S=S@entry=0x0, Parent=0x0, 
TU=0x7f8c6c5186b0, RegionOfInterest=...) at 
llvm-project/clang/tools/libclang/CXCursor.cpp:132
  #7  0x7f8caddc96e5 in clang::cxcursor::CursorVisitor::EnqueueWorkList 
(this=this@entry=0x7f8c9bffc330, WL=..., S=S@entry=0x0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3028
  #8  0x7f8cadde4e2c in clang::cxcursor::CursorVisitor::Visit 
(this=this@entry=0x7f8c9bffc330, S=0x0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3256
  #9  0x7f8cadde4604 in clang::cxcursor::CursorVisitor::RunVisitorWorkList 
(this=this@entry=0x7f8c9bffc330, WL=...) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3214
  #10 0x7f8cadde4e37 in clang::cxcursor::CursorVisitor::Visit 
(this=this@entry=0x7f8c9bffc330, S=0x7f8c6c17dc30) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3257
  #11 0x7f8cadddeccb in clang::cxcursor::CursorVisitor::VisitChildren 
(this=this@entry=0x7f8c9bffc330, Cursor=...) at 
llvm-project/clang/tools/libclang/CIndex.cpp:515
  #12 0x7f8cadde688f in clang_visitChildren (parent=..., 
visitor=0x7f8caef6ddda <(anonymous namespace)::visitCursor(CXCursor, CXCursor, 
CXClientData)>, client_data=0x7f8c9bffe3b0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:4450


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82740

Files:
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3243,6 +3243,8 @@
 }
 
 bool CursorVisitor::Visit(const Stmt *S) {
+  if (!S)
+return false;
   VisitorWorkList *WL = nullptr;
   if (!WorkListFreeList.empty()) {
 WL = WorkListFreeList.back();


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3243,6 +3243,8 @@
 }
 
 bool CursorVisitor::Visit(const Stmt *S) {
+  if (!S)
+return false;
   VisitorWorkList *WL = nullptr;
   if (!WorkListFreeList.empty()) {
 WL = WorkListFreeList.back();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78213: [libclang]: visit BindingDecl in DecompositionDecl

2020-04-23 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78213



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


[PATCH] D78214: [libclang]: visit C++17 if init statements

2020-04-23 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78214



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


[PATCH] D78214: [libclang]: visit C++17 if init statements

2020-04-15 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
milianw added reviewers: nik, yvvan.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

This makes the previously unaccessible AST nodes for C++17 "if with
init statements" accessible to consumers of libclang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78214

Files:
  clang/test/Index/cxx17-if-with-initializer.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2669,6 +2669,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 
(Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 
- 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 
(Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= 
Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 
- 5:4]


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2669,6 +2669,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 (Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 (Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 - 5:4]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78213: [libclang]: visit BindingDecl in DecompositionDecl

2020-04-15 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
milianw added reviewers: nik, yvvan.

This makes the BindingDecl accessible to consumers of libclang
as CXCursor_UnexposedDecl where previously these AST nodes were
not visited at all from the libclang API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78213

Files:
  clang/test/Index/cxx17-structured-binding.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,6 +1294,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-structured-binding.cpp
@@ -0,0 +1,25 @@
+// Test is line- and column-sensitive; see below.
+int main() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:5: FunctionDecl=main:2:5 
(Definition) Extent=[2:1 - 5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:12: CompoundStmt= Extent=[2:12 - 
5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:3: DeclStmt= Extent=[3:3 - 3:21]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:7: VarDecl=a:3:7 (Definition) 
Extent=[3:3 - 3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:9: IntegerLiteral= Extent=[3:9 - 
3:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:14: InitListExpr= Extent=[3:14 - 
3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:15: IntegerLiteral= Extent=[3:15 
- 3:16]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:18: IntegerLiteral= Extent=[3:18 
- 3:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:3: DeclStmt= Extent=[4:3 - 4:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:8: UnexposedDecl=[x, y]:4:8 
(Definition) Extent=[4:3 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:9: UnexposedDecl=x:4:9 
(Definition) Extent=[4:9 - 4:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:12: UnexposedDecl=y:4:12 
(Definition) Extent=[4:12 - 4:13]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: ArraySubscriptExpr= 
Extent=[4:17 - 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,6 +1294,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ 

[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60672



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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

Do you have commit rights? Can you push that for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60672



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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-17 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

@nik odd, it works for me, I just switched to master (previously I used the 8x 
release branch) and applied this patch and build it all. Then I run:

  $ make && ./bin/llvm-lit 
~/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  makeobj[0]: Entering directory `/home/milian/projects/build/llvm-project'
  ninja: no work to do.
  makeobj[0]: Leaving directory `/home/milian/projects/build/llvm-project'
  llvm-lit: 
/home/milian/projects/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: 
note: using clang: /home/milian/projects/build/llvm-project/bin/clang
  -- Testing: 1 tests, single process --
  PASS: Clang :: Index/cxx14-lambdas.cpp (1 of 1)
  Testing Time: 0.09s
Expected Passes: 1

Are you sure you have compiled this patch? If I comment out the visit of the 
InitExpr in CIndex.cpp again, then I get the same failure as you:

  $ make && ./bin/llvm-lit -a 
~/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  makeobj[0]: Entering directory `/home/milian/projects/build/llvm-project'
  ninja: no work to do.
  makeobj[0]: Leaving directory `/home/milian/projects/build/llvm-project'
  llvm-lit: 
/home/milian/projects/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: 
note: using clang: /home/milian/projects/build/llvm-project/bin/clang
  -- Testing: 1 tests, single process --
  FAIL: Clang :: Index/cxx14-lambdas.cpp (1 of 1)
   TEST 'Clang :: Index/cxx14-lambdas.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 13';   
/home/milian/projects/build/llvm-project/bin/c-index-test -test-load-source all 
-std=c++14 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp | 
/home/milian/projects/build/llvm-project/bin/FileCheck -check-prefix=CHECK-LOAD 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  : 'RUN: at line 30';   env CINDEXTEST_INDEXLOCALSYMBOLS=1 
/home/milian/projects/build/llvm-project/bin/c-index-test -index-file 
-std=c++14 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp | 
/home/milian/projects/build/llvm-project/bin/FileCheck 
-check-prefix=CHECK-INDEX 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp:22:16:
 error: CHECK-LOAD: expected string not found in input
  // CHECK-LOAD: cxx14-lambdas.cpp:7:27: DeclRefExpr=localA:6:9 Extent=[7:27 - 
7:33]
 ^
  :390:1: note: scanning from here
  // CHECK: cxx14-lambdas.cpp:7:59: ParmDecl=x:7:59 (Definition) Extent=[7:51 - 
7:60]
  ^
  :402:11: note: possible intended match here
  // CHECK: cxx14-lambdas.cpp:8:21: DeclRefExpr=copy:7:35 Extent=[8:21 - 8:25]
^
  
  --
  
  
  Testing Time: 0.07s
  
  Failing Tests (1):
  Clang :: Index/cxx14-lambdas.cpp
  
Unexpected Failures: 1

Re-enabling the code and building again, it works fine again:

  $ make && ./bin/llvm-lit -a 
~/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  makeobj[0]: Entering directory `/home/milian/projects/build/llvm-project'
  [5/5] Linking CXX executable bin/c-index-test
  makeobj[0]: Leaving directory `/home/milian/projects/build/llvm-project'
  llvm-lit: 
/home/milian/projects/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:340: 
note: using clang: /home/milian/projects/build/llvm-project/bin/clang
  -- Testing: 1 tests, single process --
  PASS: Clang :: Index/cxx14-lambdas.cpp (1 of 1)
  Script:
  --
  : 'RUN: at line 13';   
/home/milian/projects/build/llvm-project/bin/c-index-test -test-load-source all 
-std=c++14 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp | 
/home/milian/projects/build/llvm-project/bin/FileCheck -check-prefix=CHECK-LOAD 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  : 'RUN: at line 30';   env CINDEXTEST_INDEXLOCALSYMBOLS=1 
/home/milian/projects/build/llvm-project/bin/c-index-test -index-file 
-std=c++14 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp | 
/home/milian/projects/build/llvm-project/bin/FileCheck 
-check-prefix=CHECK-INDEX 
/home/milian/projects/src/llvm-project/clang/test/Index/cxx14-lambdas.cpp
  --
  Exit Code: 0
  
  
  
  Testing Time: 0.14s
Expected Passes: 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60672



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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-04-14 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
milianw added reviewers: clang-c, cfe-commits, hokein, nik, yvvan, marcobubke.
Herald added a subscriber: arphaman.
Herald added a project: clang.

Previously, libclang users could visit the non-init C++11 lambda
captures, e.g. `[foo]`. But C++14 init-captures such as `[foo=bar]`
were skipped, which is fixed by this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60672

Files:
  clang/test/Index/cxx14-lambdas.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3120,12 +3120,11 @@
   }
 
   case VisitorJob::LambdaExprPartsKind: {
-// Visit captures.
+// Visit non-init captures.
 const LambdaExpr *E = cast()->get();
 for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
CEnd = E->explicit_capture_end();
  C != CEnd; ++C) {
-  // FIXME: Lambda init-captures.
   if (!C->capturesVariable())
 continue;
 
@@ -3134,6 +3133,11 @@
   TU)))
 return true;
 }
+// Visit init captures
+for (auto InitExpr : E->capture_inits()) {
+  if (Visit(InitExpr))
+return true;
+}
 
 TypeLoc TL = E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
 // Visit parameters and return type, if present.
Index: clang/test/Index/cxx14-lambdas.cpp
===
--- /dev/null
+++ clang/test/Index/cxx14-lambdas.cpp
@@ -0,0 +1,38 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+  void f() {
+int localA, localB;
+auto lambda = [ptr = , copy = localB] (Integer x) -> Integer {
+  return *ptr + copy + x;
+};
+  }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++14 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx14-lambdas.cpp:7:5: DeclStmt= Extent=[7:5 - 9:7]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:10: VarDecl=lambda:7:10 (Definition) 
Extent=[7:5 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: CallExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:20: VariableRef=ptr:7:20 Extent=[7:20 - 
7:23]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:35: VariableRef=copy:7:35 Extent=[7:35 - 
7:39]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:27: DeclRefExpr=localA:6:9 Extent=[7:27 - 
7:33]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:42: DeclRefExpr=localB:6:17 Extent=[7:42 - 
7:48]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:59: ParmDecl=x:7:59 (Definition) 
Extent=[7:51 - 7:60]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:51: TypeRef=Integer:3:13 Extent=[7:51 - 
7:58]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:65: TypeRef=Integer:3:13 Extent=[7:65 - 
7:72]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:73: CompoundStmt= Extent=[7:73 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 
%s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
VariableRef=copy:7:35 | loc: 7:35
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:59 (Definition) | loc: 7:59
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:51
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:65
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
DeclRefExpr=ptr:7:20 | loc: 8:15
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
DeclRefExpr=copy:7:35 | loc: 8:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
DeclRefExpr=x:7:59 | loc: 8:28


Index: clang/tools/libclang/CIndex.cpp
===
--- 

[PATCH] D43763: libclang: Visit class template instantiations

2019-04-14 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.
Herald added a subscriber: arphaman.
Herald added a project: clang.

looks good, but this needs a test, could you add one please?


Repository:
  rC Clang

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

https://reviews.llvm.org/D43763



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


[PATCH] D37650: [continued] Add a way to get the CXCursor that corresponds to a completion result

2018-01-09 Thread Milian Wolff via Phabricator via cfe-commits
milianw requested changes to this revision.
milianw added a comment.
This revision now requires changes to proceed.

I'm pretty sure this is not ABI compatible. You change the size of 
`CXCompletionResult`, so when anyone is iterating over the array in 
`CXCompletionResults` it will break. If you don't want to, I can try to find 
some time to take this over again ;-)


Repository:
  rC Clang

https://reviews.llvm.org/D37650



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


[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2018-01-09 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

still looks good to me. can someone else please review and commit this?


Repository:
  rC Clang

https://reviews.llvm.org/D10833



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