[cfe-commits] r42411 - in /cfe/trunk: Lex/IdentifierTable.cpp include/clang/Lex/IdentifierTable.h
Chris Lattner
clattner at apple.com
Thu Sep 27 14:16:23 PDT 2007
>
> Fix bug in SelectorInfo::getName() - method buffer needs to be
> passed by reference.
Thanks, one more thing:
>
> -char *SelectorInfo::getName(llvm::SmallString<128> methodName) {
> +char *SelectorInfo::getName(llvm::SmallVectorImpl<char>
> &methodName) {
> int len=0;
I don't think you need len anymore, just use methodName.size() if you
need it.
> methodName[0] = '\0';
> if (NumArgs) {
> keyword_iterator KeyIter = keyword_begin();
> for (unsigned int i = 0; i < NumArgs; i++) {
> if (KeyIter[i]) {
> - methodName += KeyIter[i]->getName();
> - len += strlen(KeyIter[i]->getName());
> + unsigned KeyLen = strlen(KeyIter[i]->getName());
> + methodName.append(KeyIter[i]->getName(), KeyIter[i]-
> >getName()+KeyLen);
> + len += KeyLen;
> }
> - methodName += ":";
> + methodName.push_back(':');
> len++;
> }
> } else {
> IdentifierInfo **UnaryInfo = reinterpret_cast<IdentifierInfo
> **>(this+1);
> - methodName += UnaryInfo[0]->getName();
> - len += strlen(UnaryInfo[0]->getName());
> + unsigned NameLen = strlen(UnaryInfo[0]->getName());
> + methodName.append(UnaryInfo[0]->getName(), UnaryInfo[0]-
> >getName()+NameLen);
> + len += NameLen;
> }
> methodName[len] = '\0';
This should probably use methodName.push_back('\0'); to avoid writing
past the end of the vector.
-Chris
More information about the cfe-commits
mailing list