r184168 - ArrayRef'ize CodeCompletionContext::getNumSelIdents()

Dmitri Gribenko gribozavr at gmail.com
Mon Jun 17 21:44:42 PDT 2013


On Mon, Jun 17, 2013 at 9:27 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Mon, Jun 17, 2013 at 9:02 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> Author: gribozavr
>> Date: Mon Jun 17 23:02:26 2013
>> New Revision: 184168
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=184168&view=rev
>> Log:
>> ArrayRef'ize CodeCompletionContext::getNumSelIdents()
>>
>> Modified:
>>     cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
>>     cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=184168&r1=184167&r2=184168&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
>> +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Mon Jun 17 23:02:26 2013
>> @@ -303,10 +303,7 @@ public:
>>    QualType getBaseType() const { return BaseType; }
>>
>>    /// \brief Retrieve the Objective-C selector identifiers.
>> -  IdentifierInfo * const *getSelIdents() const { return SelIdents.data(); }
>> -
>> -  /// \brief Retrieve the number of Objective-C selector identifiers.
>> -  unsigned getNumSelIdents() const { return SelIdents.size(); }
>> +  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
>>
>>    /// \brief Determines whether we want C++ constructors as results within this
>>    /// context.
>>
>> Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=184168&r1=184167&r2=184168&view=diff
>> ==============================================================================
>> --- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
>> +++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Mon Jun 17 23:02:26 2013
>> @@ -562,15 +562,13 @@ namespace {
>>        AllocatedResults.Contexts = getContextsForContextKind(contextKind, S);
>>
>>        AllocatedResults.Selector = "";
>> -      if (Context.getNumSelIdents() > 0) {
>> -        for (unsigned i = 0; i < Context.getNumSelIdents(); i++) {
>> -          IdentifierInfo *selIdent = Context.getSelIdents()[i];
>> -          if (selIdent != NULL) {
>> -            StringRef selectorString = Context.getSelIdents()[i]->getName();
>> -            AllocatedResults.Selector += selectorString;
>> -          }
>> -          AllocatedResults.Selector += ":";
>> +      for (unsigned i = 0, e = Context.getSelIdents().size(); i != e; i++) {
>
> Might be nicer to use iterators here? rather than having to write
> out/call Context.getSelIdents() a couple of times on each iteration.

Of course this makes sense.  I was just doing a mechanical transformation.
Changed in r184169.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list