[cfe-commits] [Patch] adding clang_getCompletionAnnotation

Douglas Gregor dgregor at apple.com
Fri Oct 14 07:46:59 PDT 2011


On Oct 14, 2011, at 7:41 AM, Erik Verbruggen wrote:

> 
> 
> On 13 Oct, 2011,at 06:26 PM, Douglas Gregor <dgregor at applecom> 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?

Sure!


>> 
>> +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.

Looks good.

	- Doug




More information about the cfe-commits mailing list