This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Patch to remove "TODO"

Tags: None
(comma "," separated)
thyplosion
Registered Member
Posts
4
Karma
0

Patch to remove "TODO"

Mon Jan 25, 2016 2:13 pm
Hi all,

I've never ever made a patch for KDevelop; this is a first.
I've done some work (professionally) with Clang, but my experience is really in LLVM itself (transformation passes), so I hope that the patch is "ok". I also have no idea how KDEV works.

Anyway, here's the patch:

Code: Select all
diff --git a/languages/clang/codecompletion/completionhelper.cpp b/languages/clang/codecompletion/completionhelper.cpp
index c01185a..e12a9a1 100644
--- a/languages/clang/codecompletion/completionhelper.cpp
+++ b/languages/clang/codecompletion/completionhelper.cpp
@@ -55,11 +55,12 @@ struct ImplementsInfo
     QString templatePrefix;
 };

-//TODO replace this with clang_Type_getTemplateArgumentAsType when that
-//function makes it into the mainstream libclang release.
 QStringList templateTypeArguments(CXCursor cursor)
 {
     QStringList types;
+
+#if (CINDEX_VERSION <= CINDEX_VERSION_ENCODE(0,24))
+    // clang_Type_getTemplateArgumentAsType were inserted during Index version 0.24
     QString tStr = ClangString(clang_getTypeSpelling(clang_getCursorType(cursor))).toString();
     ParamIterator iter(QStringLiteral("<>"), tStr);

@@ -67,6 +68,14 @@ QStringList templateTypeArguments(CXCursor cursor)
         types.append(*iter);
         ++iter;
     }
+#else
+    CXType typeList = clang_getCursorType(cursor);
+    int templateArgCount = clang_Type_getNumTemplateArguments(typeList);
+    for (int i = 0; i < templateArgCount; ++i) {
+        ClangString clangString(clang_getTypeSpelling(clang_Type_getTemplateArgumentAsType(typeList, i)));
+        types.append(clangString.toString());
+    }
+#endif

     return types;
 }


This is possibly incomplete. It works for me (I'm using a KDev built with this), but would obviously appreciate comments.
Mind you, the include header in Clang for this function ("clang_Type_getTemplateArgumentAsType") says that this function does not support variadic templates, so potentially this patch is not acceptable.

Cheerio.
User avatar
kfunk
KDE Developer
Posts
53
Karma
0
OS

Re: Patch to remove "TODO"  Topic is solved

Mon Jan 25, 2016 4:55 pm
Would you mind posting that patch to our code review site? It definitely looks useful from a quick glance.

See: https://techbase.kde.org/Contribute/Sen ... habricator
thyplosion
Registered Member
Posts
4
Karma
0

Re: Patch to remove "TODO"

Tue Jan 26, 2016 10:27 am
kfunk wrote:Would you mind posting that patch to our code review site? It definitely looks useful from a quick glance.

See: https://techbase.kde.org/Contribute/Sen ... habricator


Silly me - sorry I didn't realise that existed. Will do. Thank you!


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]