[cfe-commits] [Patch] adding clang_getCompletionAnnotation

Erik Verbruggen erik.verbruggen at me.com
Fri Oct 14 07:41:45 PDT 2011

On 13 Oct, 2011,at 06:26 PM, Douglas Gregor <dgregor at apple.com> wrote:

--- a/include/clang/Sema/CodeCompleteConsumer.h
+++ b/include/clang/Sema/CodeCompleteConsumer.h
@@ -435,12 +435,15 @@ private:

/// \brief The availability of this code-completion result.
unsigned Availability : 2;
+ unsigned NumAnnotations;

Shouldn't we use less than 32 bits for the number of annotations?
I changed it to unsigned NumAnnotations : 8 but with alignment I do not know if this will have any impact. Also, there is a unsigned NumChunks (so a full 32 bit unsigned), which I guess is also be a bit on the large side. So maybe I should give them both a :16?

+CXString clang_getCompletionAnnotation(CXCompletionString completion_string,
+ unsigned annotation_number) {
+ CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+ return CCStr? createCXString(CCStr->getAnnotation(annotation_number))
+ : createCXString((const char *) 0);

Returning an empty CXString to mean "no more annotations" makes for a very subtle distinction with, e.g.,

int blah __attribute__((annotate("one"), annotate(""), annotate("three")));

I'd feel slightly better if there were a clang_getCompletionNumAnnotations(CXCompletionString) function for the client to use.
Done, and I added that line above to the test. New patch attached.

-- Erik.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111014/b27d6378/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-clang_getCompletionAnnotation-and-clang_getCom.patch
Type: application/octet-stream
Size: 12318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111014/b27d6378/attachment.obj>

More information about the cfe-commits mailing list