[PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-10-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping?


https://reviews.llvm.org/D10834



___
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

2016-10-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Has this been merged yet?


https://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-28 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2016-04-28 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2016-04-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2016-04-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D18752: Documented standard substitutions defined by lit

2016-04-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Thanks for the advice.

Please use Guilherme Bufolo as the name for the commit.
Am 04.04.2016 21:33 schrieb "Paul Robinson" <
paul_robin...@playstation.sony.com>:

> probinson added a subscriber: probinson.

>  probinson added a comment.

> 

> In http://reviews.llvm.org/D18752#390906, @RedX2501 wrote:

> 

> > Somebody else needs to commit this as I don't have any rights for it.

> 

> When someone else commits for you, our practice is to attribute the

>  correct author in the commit message.

>  This is more than a courtesy, because you retain copyright of any changes

>  you have made.  Therefore we prefer to use your actual name rather than a

>  handle such as RedX2501, guibufolo, or Guilherme.

>  What name would you like us to use?

> 

> http://reviews.llvm.org/D18752



http://reviews.llvm.org/D18752



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


Re: [PATCH] D18752: Documented standard substitutions defined by lit

2016-04-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 52531.
RedX2501 added a comment.

I had a hard time myself figuring out what tmpbase and tmpdir are. I have used 
your wording.

Somebody else needs to commit this as I don't have any rights for it.


http://reviews.llvm.org/D18752

Files:
  docs/CommandGuide/lit.rst

Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,35 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various patterns that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t temporary file name unique to the test
+ %T temporary directory unique to the test
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
+More information on the testing infrastucture can be found in the
+:doc:`../TestingGuide`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 


Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,35 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various patterns that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t temporary file name unique to the test
+ %T temporary directory unique to the test
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
+More information on the testing infrastucture can be found in the
+:doc:`../TestingGuide`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18752: Documented standard substitutions defined by lit

2016-04-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 52530.
RedX2501 added a comment.

Added reference to testing infrastructure document.


http://reviews.llvm.org/D18752

Files:
  docs/CommandGuide/lit.rst

Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,35 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various macros that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t tmpbase + ".tmp"
+ %T tmpdir
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
+More information on the testing infrastucture can be found in the
+:doc:`../TestingGuide`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 


Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,35 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various macros that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t tmpbase + ".tmp"
+ %T tmpdir
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
+More information on the testing infrastucture can be found in the
+:doc:`../TestingGuide`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18752: Documented standard substitutions defined by lit

2016-04-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 created this revision.
RedX2501 added reviewers: EricWF, MatzeB, echristo, jroelofs.
RedX2501 added a subscriber: cfe-commits.

http://reviews.llvm.org/D18752

Files:
  docs/CommandGuide/lit.rst

Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,32 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various macros that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t tmpbase + ".tmp"
+ %T tmpdir
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 


Index: docs/CommandGuide/lit.rst
===
--- docs/CommandGuide/lit.rst
+++ docs/CommandGuide/lit.rst
@@ -355,6 +355,32 @@
 configuration parameters --- for example, to change the test format, or the
 suffixes which identify test files.
 
+PRE-DEFINED SUBSTITUTIONS
+~~
+
+:program:`lit` provides various macros that can be used with the RUN command.
+These are defined in TestRunner.py.
+
+ == ==
+  Macro  Substitution
+ == ==
+ %s source path (path to the file currently being run)
+ %S source dir (directory of the file currently being run)
+ %p same as %S
+ %{pathsep} path separator
+ %t tmpbase + ".tmp"
+ %T tmpdir
+ %% %
+ %/ssame as %s but replace all / with \\
+ %/Ssame as %S but replace all / with \\
+ %/psame as %p but replace all / with \\
+ %/tsame as %t but replace all / with \\
+ %/Tsame as %T but replace all / with \\
+ == ==
+
+Further substitution patterns might be defined by each test module.
+See the modules :ref:`local-configuration-files`.
+
 TEST RUN OUTPUT FORMAT
 ~~
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-01 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 52367.
RedX2501 added a comment.

Fix compilation error introduced due to breaking a long string.
Fixed indentation.


http://reviews.llvm.org/D10834

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/islocalvardecl.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -33,6 +33,7 @@
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic
+clang_Cursor_isLocalVarDecl
 clang_Cursor_getModule
 clang_Cursor_getStorageClass
 clang_File_isEqual
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6921,6 +6921,19 @@
   return 0;
 }
 
+unsigned clang_Cursor_isLocalVarDecl(CXCursor C){
+  if (C.kind != CXCursor_VarDecl) {
+return 0;
+  }
+
+  const Decl *D = getCursorDecl(C);
+  if (const VarDecl *VD = dyn_cast(D)) {
+return VD->isLocalVarDecl();
+  }
+
+  return 0;
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1276,6 +1276,22 @@
 }
 
 /**/
+/* Local VarKind testing. */
+/**/
+
+static enum CXChildVisitResult PrintIsLocalVarDecl(CXCursor C, CXCursor p,
+   CXClientData d){
+
+  if (clang_getCursorKind(C) != CXCursor_VarDecl)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  printf(" IsLocalVarDecl=%d\n", clang_Cursor_isLocalVarDecl(C));
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  */
 /**/
 
@@ -4150,10 +4166,12 @@
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
 "   c-index-test -test-print-visibility {}*\n"
+"   c-index-test -test-print-is-local-var {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
-"   c-index-test -test-print-type-declaration {}*\n"
+"   c-index-test -test-print-type-declaration {}*\n");
+  fprintf(stderr,
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4241,6 +4259,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-visibility") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintVisibility,
 NULL);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-is-local-var") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all", PrintIsLocalVarDecl,
+NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-type") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintType, 0);
Index: test/Index/islocalvardecl.cpp
===
--- /dev/null
+++ test/Index/islocalvardecl.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test -test-print-local-var-kind %s | FileCheck %s
+
+extern "C" {
+  int var0;
+  static int var1;
+
+  void func(void){
+static int var2;
+int var3;
+  }
+};
+
+int var4;
+
+class Classy {
+  static int var5;
+
+  void member(){
+int var6;
+static int var7;
+  }
+};
+
+// CHECK: VarDecl=var0:3:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var1:4:12 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var2:7:14 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var3:8:7 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var4:13:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var5:17:12 IsLocalVarDecl=0
+// CHECK: VarDecl=var6:20:9 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var7:21:16 (Definition) IsLocalVarDecl=1
+
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3882,6 +3882,11 @@
 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
 
 /**
+ * \brief Returns non-zero if the Cursor refers to a local VarDecl.
+ */
+CINDEX_LINKAGE 

Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-01 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 52358.
RedX2501 added a comment.

Fixed compiler warnings.


http://reviews.llvm.org/D10834

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/islocalvardecl.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -33,6 +33,7 @@
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic
+clang_Cursor_isLocalVarDecl
 clang_Cursor_getModule
 clang_Cursor_getStorageClass
 clang_File_isEqual
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6921,6 +6921,19 @@
   return 0;
 }
 
+unsigned clang_Cursor_isLocalVarDecl(CXCursor C){
+  if (C.kind != CXCursor_VarDecl) {
+return 0;
+  }
+
+  const Decl *D = getCursorDecl(C);
+  if (const VarDecl *VD = dyn_cast(D)) {
+		return VD->isLocalVarDecl();
+	}
+
+	return 0;
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1276,6 +1276,22 @@
 }
 
 /**/
+/* Local VarKind testing. */
+/**/
+
+static enum CXChildVisitResult PrintIsLocalVarDecl(CXCursor C, CXCursor p,
+   CXClientData d){
+
+  if (clang_getCursorKind(C) != CXCursor_VarDecl)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  printf(" IsLocalVarDecl=%d\n", clang_Cursor_isLocalVarDecl(C));
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  */
 /**/
 
@@ -4150,10 +4166,12 @@
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
 "   c-index-test -test-print-visibility {}*\n"
+"   c-index-test -test-print-is-local-var {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
 "   c-index-test -test-print-type-declaration {}*\n"
+  fprintf(stderr,
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4241,6 +4259,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-visibility") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintVisibility,
 NULL);
+	else if (argc > 2 && strcmp(argv[1], "-test-print-is-local-var") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all", PrintIsLocalVarDecl,
+NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-type") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintType, 0);
Index: test/Index/islocalvardecl.cpp
===
--- /dev/null
+++ test/Index/islocalvardecl.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test -test-print-local-var-kind %s | FileCheck %s
+
+extern "C" {
+  int var0;
+  static int var1;
+
+  void func(void){
+static int var2;
+int var3;
+  }
+};
+
+int var4;
+
+class Classy {
+  static int var5;
+
+  void member(){
+int var6;
+static int var7;
+  }
+};
+
+// CHECK: VarDecl=var0:3:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var1:4:12 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var2:7:14 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var3:8:7 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var4:13:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var5:17:12 IsLocalVarDecl=0
+// CHECK: VarDecl=var6:20:9 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var7:21:16 (Definition) IsLocalVarDecl=1
+
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3882,6 +3882,11 @@
 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
 
 /**
+ * \brief Returns non-zero if the Cursor refers to a local VarDecl.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isLocalVarDecl(CXCursor C);
+
+/**
  * \brief Given a cursor that represents a declaration, return the 

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

2016-01-09 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-12-27 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-12-20 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-12-09 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

In http://reviews.llvm.org/D10833#306281, @akyrtzi wrote:

> The patch causes tests to fail, please look into it.


Where can i see the test reports? I'm having trouble running the test on my 
side on windows (VS2013).


http://reviews.llvm.org/D10833



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


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

2015-12-09 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 42386.
RedX2501 added a comment.

Added functions to libclang.exports.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -14,6 +14,8 @@
 clang_Cursor_getTemplateArgumentValue
 clang_Cursor_getTemplateArgumentUnsignedValue
 clang_Cursor_getBriefCommentText
+clang_Cursor_getBinaryOpcode
+clang_Cursor_getBinaryOpcodeStr
 clang_Cursor_getCommentRange
 clang_Cursor_getCXXManglings
 clang_Cursor_getMangling
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3799,6 +3799,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpcodeStr(clang_Cursor_getBinaryOpcode(C));
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6892,6 +6897,29 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpcode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op) {
+	if (Op > CX_BO_LAST) {
+		return cxstring::createEmpty();
+	}
+
+	return cxstring::createDup(
+			BinaryOperator::getOpcodeStr(static_cast(Op - 1)));
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1451,6 +1451,20 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpcode(C);
+  CXString opstr = clang_Cursor_getBinaryOpcodeStr(bok);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4114,6 +4128,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4210,6 +4225,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-manglings") == 0)
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = ::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ 

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

2015-12-08 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 42267.
RedX2501 added a comment.

Added explicit integer assignment to enum to emphasize api contract behaviour.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3799,6 +3799,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpcodeStr(clang_Cursor_getBinaryOpcode(C));
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6892,6 +6897,29 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpcode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op) {
+	if (Op > CX_BO_LAST) {
+		return cxstring::createEmpty();
+	}
+
+	return cxstring::createDup(
+			BinaryOperator::getOpcodeStr(static_cast(Op - 1)));
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1451,6 +1451,20 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpcode(C);
+  CXString opstr = clang_Cursor_getBinaryOpcodeStr(bok);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4114,6 +4128,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4210,6 +4225,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-manglings") == 0)
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = ::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ BinOp=/ 4
+// CHECK: BinaryOperator=% BinOp=% 5
+// CHECK: BinaryOperator=+ BinOp=+ 6
+// CHECK: BinaryOperator=- BinOp=- 7
+// CHECK: BinaryOperator=<< BinOp=<< 8
+// CHECK: BinaryOperator=>> BinOp=>> 9
+// CHECK: BinaryOperator=< BinOp=< 10
+// CHECK: BinaryOperator=> BinOp=> 11
+// CHECK: BinaryOperator=<= BinOp=<= 12
+// CHECK: BinaryOperator=>= BinOp=>= 13
+// CHECK: BinaryOperator=== BinOp=== 14
+// CHECK: BinaryOperator=!= BinOp=!= 15
+// CHECK: 

Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2015-12-06 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2015-12-06 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-11-29 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2015-11-23 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2015-11-20 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-11-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 marked 2 inline comments as done.


Comment at: bindings/python/tests/cindex/test_cursor.py:333
@@ +332,3 @@
+# not exposed yet
+# ".*" : BinaryOperator.PtrMemD,
+"->*" : BinaryOperator.PtrMemI,

kfunk wrote:
> What about this? How is it not exposed? 
> 
> This works in the C++ test apparently(?)
Yeah, I was surprised too. I have no idea why one is exposed and the other 
not...

But i don't feel like investigating it as I don't need it and this operator is 
not used often.


http://reviews.llvm.org/D10833



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


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

2015-11-04 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 39176.
RedX2501 added a comment.

Changed points raised during review.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3725,6 +3725,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpcodeStr(clang_Cursor_getBinaryOpcode(C));
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6741,6 +6746,29 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpcode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op) {
+	if (Op > CX_BO_LAST) {
+		return cxstring::createEmpty();
+	}
+
+	return cxstring::createDup(
+			BinaryOperator::getOpcodeStr(static_cast(Op - 1)));
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1425,6 +1425,21 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpcode(C);
+  CXString opstr = clang_Cursor_getBinaryOpcodeStr(bok);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4068,6 +4083,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4161,6 +4177,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 1 && strcmp(argv[1], "-print-usr") == 0) {
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = ::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ BinOp=/ 4
+// CHECK: BinaryOperator=% BinOp=% 5
+// CHECK: BinaryOperator=+ BinOp=+ 6
+// CHECK: BinaryOperator=- BinOp=- 7
+// CHECK: BinaryOperator=<< BinOp=<< 8
+// CHECK: BinaryOperator=>> BinOp=>> 9
+// CHECK: BinaryOperator=< BinOp=< 10
+// CHECK: BinaryOperator=> BinOp=> 11
+// CHECK: BinaryOperator=<= BinOp=<= 12
+// CHECK: BinaryOperator=>= BinOp=>= 13
+// CHECK: BinaryOperator=== BinOp=== 14
+// CHECK: BinaryOperator=!= BinOp=!= 15
+// CHECK: BinaryOperator=& BinOp=& 16
+// CHECK: 

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

2015-11-03 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 39158.
RedX2501 added a comment.

Added module tests to libclang and python.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3725,6 +3725,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpCodeStr(C);
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6741,6 +6746,34 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpCode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpCodeStr(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return cxstring::createEmpty();
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return cxstring::createDup(BinOp->getOpcodeStr());
+	}
+
+	return cxstring::createEmpty();
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1425,6 +1425,21 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  CXString opstr = clang_Cursor_getBinaryOpCodeStr(C);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpCode(C);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4068,6 +4083,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4161,6 +4177,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 1 && strcmp(argv[1], "-print-usr") == 0) {
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = ::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ BinOp=/ 4
+// CHECK: BinaryOperator=% BinOp=% 5
+// CHECK: BinaryOperator=+ BinOp=+ 6
+// CHECK: BinaryOperator=- BinOp=- 7
+// CHECK: BinaryOperator=<< BinOp=<< 8
+// CHECK: BinaryOperator=>> BinOp=>> 9
+// CHECK: BinaryOperator=< BinOp=< 10
+// CHECK: BinaryOperator=> BinOp=> 11
+// CHECK: BinaryOperator=<= BinOp=<= 12
+// CHECK: BinaryOperator=>= BinOp=>= 13
+// CHECK: BinaryOperator=== 

Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2015-11-03 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 retitled this revision from "Added functions to retrieve information 
about variable storage in libclang and its python bindings." to "Added 
functions to retrieve information about whether a vardecl is local in libclang 
and its python bindings.".
RedX2501 updated this revision to Diff 39163.
RedX2501 added a comment.

No longer export to functions but only one.
The original functionality can be achieved by using StorageClass coupled with 
the information if the variable is local.

Added python and libclang tests.


http://reviews.llvm.org/D10834

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/islocalvardecl.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -32,6 +32,7 @@
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic
+clang_Cursor_isLocalVarDecl
 clang_Cursor_getModule
 clang_Cursor_getStorageClass
 clang_File_isEqual
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6741,6 +6741,19 @@
   return 0;
 }
 
+unsigned clang_Cursor_isLocalVarDecl(CXCursor C){
+  if (C.kind != CXCursor_VarDecl) {
+return 0;
+  }
+
+  const Decl *D = getCursorDecl(C);
+  if (const VarDecl *VD = dyn_cast(D)) {
+		return VD->isLocalVarDecl();
+	}
+
+	return 0;
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1248,6 +1248,21 @@
 }
 
 /**/
+/* Local VarKind testing. */
+/**/
+
+static enum ChildVisitResult PrintIsLocalVarDecl(CXCursor C, CXClientData CD){
+
+  if (clang_getCursorKind(C) != CXCursor_VarDecl)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  printf(" IsLocalVarDecl=%d\n", clang_Cursor_isLocalVarDecl(C));
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  */
 /**/
 
@@ -4065,6 +4080,7 @@
 "   c-index-test -test-inclusion-stack-tu \n");
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
+"   c-index-test -test-print-is-local-var {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
@@ -4152,6 +4168,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
 NULL);
+	else if (argc > 2 && strcmp(argv[1], "-test-print-is-local-var") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all", PrintIsLocalVarDecl,
+NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-type") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintType, 0);
Index: test/Index/islocalvardecl.cpp
===
--- /dev/null
+++ test/Index/islocalvardecl.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test -test-print-local-var-kind %s | FileCheck %s
+
+extern "C" {
+  int var0;
+  static int var1;
+
+  void func(void){
+static int var2;
+int var3;
+  }
+};
+
+int var4;
+
+class Classy {
+  static int var5;
+
+  void member(){
+int var6;
+static int var7;
+  }
+};
+
+// CHECK: VarDecl=var0:3:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var1:4:12 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var2:7:14 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var3:8:7 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var4:13:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var5:17:12 IsLocalVarDecl=0
+// CHECK: VarDecl=var6:20:9 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var7:21:16 (Definition) IsLocalVarDecl=1
+
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3829,6 +3829,11 @@
 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
 
 /**
+ * \brief Returns non-zero if the Cursor refers to a local VarDecl.
+ 

Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-10-11 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added inline comments.


Comment at: include/clang-c/Index.h:3815-3823
@@ -3814,2 +3814,11 @@
 
 /**
+ * \brief Returns true if a variable with function scope is a non-static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_hasLocalStorage(CXCursor C);
+
+/*
+ * \brief  Returns true if a variable with function scope is a static local 
variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_isStaticLocal(CXCursor C);
+

rsmith wrote:
> It might be better to combine these into a single function 
> (`getLocalVarKind`?) returning an enum { not local, non-static local, static 
> local }.
Combining these into one function with an enum is much more work when porting 
to python (which is also den in this patch). Therefore unless there are reasons 
beyond stylistic ones i'd prefer to keep them separate.

IMHO this also increases the friendliness as you can directly infer from the 
documentation at http://clang.llvm.org/doxygen/ what they should do as they 
just forward the calls..


http://reviews.llvm.org/D10834



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


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

2015-09-22 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-09-03 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-08-24 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2015-08-24 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


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

2015-08-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a reviewer: doug.gregor.
RedX2501 added a comment.

The code owners file says you are the owner of all parts that do not belong to 
somebody else. So i hope it is ok if i attach you as reviewer to this.


http://reviews.llvm.org/D10833



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


Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-08-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a reviewer: doug.gregor.
RedX2501 added a comment.

The code owners file says you are the owner of all parts that do not belong to 
somebody else. So i hope it is ok if i attach you as reviewer to this.


http://reviews.llvm.org/D10834



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


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

2015-08-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


Re: [PATCH] D5538: Added function to retrieve storage class in libclang.

2015-08-10 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 accepted this revision.
RedX2501 added a reviewer: RedX2501.
RedX2501 added a comment.
This revision is now accepted and ready to land.

This was accepted into r219809.


http://reviews.llvm.org/D5538



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