[geany/geany] 95a0d4: c++: Properly parse C++11 override and final members

Colomban Wendling git-noreply at xxxxx
Wed Jul 1 10:55:29 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 01 Jul 2015 10:55:29 UTC
Commit:      95a0d4db7e2188a62cf7770496ee2a51591f1962
             https://github.com/geany/geany/commit/95a0d4db7e2188a62cf7770496ee2a51591f1962

Log Message:
-----------
c++: Properly parse C++11 override and final members

As `override` and `final` aren't real keywords, handle them manually
not to break identifiers of those names.


Modified Paths:
--------------
    tagmanager/ctags/c.c
    tests/ctags/Makefile.am
    tests/ctags/cxx11-final.cpp
    tests/ctags/cxx11-override.cpp
    tests/ctags/cxx11-override.cpp.tags

Modified: tagmanager/ctags/c.c
8 lines changed, 7 insertions(+), 1 deletions(-)
===================================================================
@@ -2262,7 +2262,13 @@ static boolean skipPostArgumentStuff (statementInfo *const st,
 						break;
 
 					default:
-						if (isType (token, TOKEN_NONE))
+						/* "override" and "final" are only keywords in the declaration of a virtual
+						 * member function, so need to be handled specially, not as keywords */
+						if (isLanguage(Lang_cpp) && isType (token, TOKEN_NAME) &&
+							(strcmp ("override", vStringValue (token->name)) == 0 ||
+							 strcmp ("final", vStringValue (token->name)) == 0))
+							;
+						else if (isType (token, TOKEN_NONE))
 							;
 						else if (info->isKnrParamList  &&  info->parameterCount > 0)
 							++elementCount;


Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -133,6 +133,7 @@ test_sources = \
 	cython_sample2.pyx				\
 	cxx11enum.cpp					\
 	cxx11-final.cpp					\
+	cxx11-override.cpp				\
 	db-trig.sql						\
 	debian_432872.f90				\
 	directives.c					\


Modified: tests/ctags/cxx11-final.cpp
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -6,7 +6,7 @@ class Base
 
 class Derived final : public Base
 {
-	virtual void foo();
+	virtual void foo() final;
 	virtual void final();
 };
 


Modified: tests/ctags/cxx11-override.cpp
23 lines changed, 23 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,23 @@
+class Base
+{
+public:
+	virtual void foo() = 0;
+};
+
+class Derived : public Base
+{
+	virtual void foo() override;
+	virtual void override();
+};
+
+void Base::foo()
+{
+}
+
+void Derived::foo()
+{
+}
+
+void Derived::override()
+{
+}


Modified: tests/ctags/cxx11-override.cpp.tags
9 lines changed, 9 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,9 @@
+# format=tagmanager
+Base�1�0
+Derived�1�0
+foo�16�()�Base�0�void
+foo�16�()�Derived�0�void
+foo�1024�()�Base�0�virtual void
+foo�1024�()�Derived�0�virtual void
+override�16�()�Derived�0�void
+override�1024�()�Derived�0�virtual void



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list