Move clients to use IdentifierInfo::getNameStart() instead of getName()

llvm-svn: 84436
This commit is contained in:
Daniel Dunbar 2009-10-18 20:26:12 +00:00
parent e175bb1941
commit 2c422dc9ca
22 changed files with 59 additions and 60 deletions

View File

@ -231,6 +231,8 @@ std::string NamedDecl::getQualifiedNameAsString() const {
} }
std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const { std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const {
// FIXME: Collect contexts, then accumulate names to avoid unnecessary
// std::string thrashing.
std::vector<std::string> Names; std::vector<std::string> Names;
std::string QualName; std::string QualName;
const DeclContext *Ctx = getDeclContext(); const DeclContext *Ctx = getDeclContext();
@ -252,7 +254,7 @@ std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const {
TemplateArgs.getFlatArgumentList(), TemplateArgs.getFlatArgumentList(),
TemplateArgs.flat_size(), TemplateArgs.flat_size(),
P); P);
Names.push_back(Spec->getIdentifier()->getName() + TemplateArgsStr); Names.push_back(Spec->getIdentifier()->getNameStart() + TemplateArgsStr);
} else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx)) } else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx))
Names.push_back(ND->getNameAsString()); Names.push_back(ND->getNameAsString());
else else

View File

@ -117,7 +117,7 @@ void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
} }
const char *LabelStmt::getName() const { const char *LabelStmt::getName() const {
return getID()->getName(); return getID()->getNameStart();
} }
// This is defined here to avoid polluting Stmt.h with importing Expr.h // This is defined here to avoid polluting Stmt.h with importing Expr.h

View File

@ -244,7 +244,7 @@ void StmtDumper::DumpDeclarator(Decl *D) {
// print a free standing tag decl (e.g. "struct x;"). // print a free standing tag decl (e.g. "struct x;").
const char *tagname; const char *tagname;
if (const IdentifierInfo *II = TD->getIdentifier()) if (const IdentifierInfo *II = TD->getIdentifier())
tagname = II->getName(); tagname = II->getNameStart();
else else
tagname = "<anonymous>"; tagname = "<anonymous>";
fprintf(F, "\"%s %s;\"", TD->getKindName(), tagname); fprintf(F, "\"%s %s;\"", TD->getKindName(), tagname);
@ -253,7 +253,7 @@ void StmtDumper::DumpDeclarator(Decl *D) {
// print using-directive decl (e.g. "using namespace x;") // print using-directive decl (e.g. "using namespace x;")
const char *ns; const char *ns;
if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier()) if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier())
ns = II->getName(); ns = II->getNameStart();
else else
ns = "<anonymous>"; ns = "<anonymous>";
fprintf(F, "\"%s %s;\"",UD->getDeclKindName(), ns); fprintf(F, "\"%s %s;\"",UD->getDeclKindName(), ns);
@ -403,7 +403,7 @@ void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
} }
void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) { void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
fprintf(F, " %s", Node->getAccessor().getName()); fprintf(F, " %s", Node->getAccessor().getNameStart());
} }
void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) { void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
DumpExpr(Node); DumpExpr(Node);
@ -495,7 +495,7 @@ void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
DumpExpr(Node); DumpExpr(Node);
fprintf(F, " selector=%s", Node->getSelector().getAsString().c_str()); fprintf(F, " selector=%s", Node->getSelector().getAsString().c_str());
IdentifierInfo* clsName = Node->getClassName(); IdentifierInfo* clsName = Node->getClassName();
if (clsName) fprintf(F, " class=%s", clsName->getName()); if (clsName) fprintf(F, " class=%s", clsName->getNameStart());
} }
void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) { void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {

View File

@ -1502,11 +1502,11 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
const char *Kind = Policy.SuppressTagKind? 0 : getDecl()->getKindName(); const char *Kind = Policy.SuppressTagKind? 0 : getDecl()->getKindName();
const char *ID; const char *ID;
if (const IdentifierInfo *II = getDecl()->getIdentifier()) if (const IdentifierInfo *II = getDecl()->getIdentifier())
ID = II->getName(); ID = II->getNameStart();
else if (TypedefDecl *Typedef = getDecl()->getTypedefForAnonDecl()) { else if (TypedefDecl *Typedef = getDecl()->getTypedefForAnonDecl()) {
Kind = 0; Kind = 0;
assert(Typedef->getIdentifier() && "Typedef without identifier?"); assert(Typedef->getIdentifier() && "Typedef without identifier?");
ID = Typedef->getIdentifier()->getName(); ID = Typedef->getIdentifier()->getNameStart();
} else } else
ID = "<anonymous>"; ID = "<anonymous>";

View File

@ -45,9 +45,9 @@ static const ObjCInterfaceType* GetReceiverType(const ObjCMessageExpr* ME) {
} }
static const char* GetReceiverNameType(const ObjCMessageExpr* ME) { static const char* GetReceiverNameType(const ObjCMessageExpr* ME) {
const ObjCInterfaceType *ReceiverType = GetReceiverType(ME); if (const ObjCInterfaceType *ReceiverType = GetReceiverType(ME))
return ReceiverType ? ReceiverType->getDecl()->getIdentifier()->getName() return ReceiverType->getDecl()->getIdentifier()->getNameStart();
: NULL; return NULL;
} }
namespace { namespace {

View File

@ -931,7 +931,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
// [PR 3337] Use 'getAs<FunctionType>' to strip away any typedefs on the // [PR 3337] Use 'getAs<FunctionType>' to strip away any typedefs on the
// function's type. // function's type.
const FunctionType* FT = FD->getType()->getAs<FunctionType>(); const FunctionType* FT = FD->getType()->getAs<FunctionType>();
const char* FName = FD->getIdentifier()->getName(); const char* FName = FD->getIdentifier()->getNameStart();
// Strip away preceding '_'. Doing this here will effect all the checks // Strip away preceding '_'. Doing this here will effect all the checks
// down below. // down below.

View File

@ -1445,10 +1445,9 @@ static void MarkNoReturnFunction(const FunctionDecl *FD, CallExpr *CE,
// HACK: Some functions are not marked noreturn, and don't return. // HACK: Some functions are not marked noreturn, and don't return.
// Here are a few hardwired ones. If this takes too long, we can // Here are a few hardwired ones. If this takes too long, we can
// potentially cache these results. // potentially cache these results.
const char* s = FD->getIdentifier()->getName(); const char* s = FD->getIdentifier()->getNameStart();
unsigned n = strlen(s);
switch (n) { switch (FD->getIdentifier()->getLength()) {
default: default:
break; break;

View File

@ -825,7 +825,7 @@ llvm::Constant *
CodeGenModule::CreateRuntimeFunction(const llvm::FunctionType *FTy, CodeGenModule::CreateRuntimeFunction(const llvm::FunctionType *FTy,
const char *Name) { const char *Name) {
// Convert Name to be a uniqued string from the IdentifierInfo table. // Convert Name to be a uniqued string from the IdentifierInfo table.
Name = getContext().Idents.get(Name).getName(); Name = getContext().Idents.get(Name).getNameStart();
return GetOrCreateLLVMFunction(Name, FTy, GlobalDecl()); return GetOrCreateLLVMFunction(Name, FTy, GlobalDecl());
} }
@ -911,7 +911,7 @@ llvm::Constant *
CodeGenModule::CreateRuntimeVariable(const llvm::Type *Ty, CodeGenModule::CreateRuntimeVariable(const llvm::Type *Ty,
const char *Name) { const char *Name) {
// Convert Name to be a uniqued string from the IdentifierInfo table. // Convert Name to be a uniqued string from the IdentifierInfo table.
Name = getContext().Idents.get(Name).getName(); Name = getContext().Idents.get(Name).getNameStart();
return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0); return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0);
} }
@ -1254,7 +1254,7 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
// Unique the name through the identifier table. // Unique the name through the identifier table.
const char *AliaseeName = AA->getAliasee().c_str(); const char *AliaseeName = AA->getAliasee().c_str();
AliaseeName = getContext().Idents.get(AliaseeName).getName(); AliaseeName = getContext().Idents.get(AliaseeName).getNameStart();
// Create a reference to the named value. This ensures that it is emitted // Create a reference to the named value. This ensures that it is emitted
// if a deferred decl. // if a deferred decl.
@ -1341,7 +1341,7 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
cast<llvm::FunctionType>(getTypes().ConvertType(Type)); cast<llvm::FunctionType>(getTypes().ConvertType(Type));
// Unique the name through the identifier table. // Unique the name through the identifier table.
Name = getContext().Idents.get(Name).getName(); Name = getContext().Idents.get(Name).getNameStart();
return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl(FD)); return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl(FD));
} }

View File

@ -591,7 +591,7 @@ public:
static std::pair<unsigned,unsigned> static std::pair<unsigned,unsigned>
EmitKeyDataLength(llvm::raw_ostream& Out, const PTHIdKey* key, uint32_t) { EmitKeyDataLength(llvm::raw_ostream& Out, const PTHIdKey* key, uint32_t) {
unsigned n = strlen(key->II->getName()) + 1; unsigned n = key->II->getLength() + 1;
::Emit16(Out, n); ::Emit16(Out, n);
return std::make_pair(n, sizeof(uint32_t)); return std::make_pair(n, sizeof(uint32_t));
} }
@ -600,7 +600,7 @@ public:
// Record the location of the key data. This is used when generating // Record the location of the key data. This is used when generating
// the mapping from persistent IDs to strings. // the mapping from persistent IDs to strings.
key->FileOffset = Out.tell(); key->FileOffset = Out.tell();
Out.write(key->II->getName(), n); Out.write(key->II->getNameStart(), n);
} }
static void EmitData(llvm::raw_ostream& Out, PTHIdKey*, uint32_t pID, static void EmitData(llvm::raw_ostream& Out, PTHIdKey*, uint32_t pID,

View File

@ -1505,7 +1505,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
IdentifierInfo *II = Identifiers[I]; IdentifierInfo *II = Identifiers[I];
// Look in the on-disk hash table for an entry for // Look in the on-disk hash table for an entry for
PCHIdentifierLookupTrait Info(*this, II); PCHIdentifierLookupTrait Info(*this, II);
std::pair<const char*, unsigned> Key(II->getName(), II->getLength()); std::pair<const char*, unsigned> Key(II->getNameStart(), II->getLength());
PCHIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Info); PCHIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Info);
if (Pos == IdTable->end()) if (Pos == IdTable->end())
continue; continue;

View File

@ -1594,7 +1594,7 @@ public:
std::pair<unsigned,unsigned> std::pair<unsigned,unsigned>
EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II, EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II,
pch::IdentID ID) { pch::IdentID ID) {
unsigned KeyLen = strlen(II->getName()) + 1; unsigned KeyLen = II->getLength() + 1;
unsigned DataLen = 4; // 4 bytes for the persistent ID << 1 unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
if (isInterestingIdentifier(II)) { if (isInterestingIdentifier(II)) {
DataLen += 2; // 2 bytes for builtin ID, flags DataLen += 2; // 2 bytes for builtin ID, flags
@ -1619,7 +1619,7 @@ public:
// Record the location of the key data. This is used when generating // Record the location of the key data. This is used when generating
// the mapping from persistent IDs to strings. // the mapping from persistent IDs to strings.
Writer.SetIdentifierOffset(II, Out.tell()); Writer.SetIdentifierOffset(II, Out.tell());
Out.write(II->getName(), KeyLen); Out.write(II->getNameStart(), KeyLen);
} }
void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II, void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II,

View File

@ -2289,7 +2289,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 8> ClsExprs; llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy); QualType argType = Context->getPointerType(Context->CharTy);
ClsExprs.push_back(StringLiteral::Create(*Context, ClsExprs.push_back(StringLiteral::Create(*Context,
SuperDecl->getIdentifier()->getName(), SuperDecl->getIdentifier()->getNameStart(),
SuperDecl->getIdentifier()->getLength(), SuperDecl->getIdentifier()->getLength(),
false, argType, SourceLocation())); false, argType, SourceLocation()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl, CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl,
@ -2343,7 +2343,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 8> ClsExprs; llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy); QualType argType = Context->getPointerType(Context->CharTy);
ClsExprs.push_back(StringLiteral::Create(*Context, ClsExprs.push_back(StringLiteral::Create(*Context,
clsName->getName(), clsName->getNameStart(),
clsName->getLength(), clsName->getLength(),
false, argType, false, argType,
SourceLocation())); SourceLocation()));
@ -2375,7 +2375,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 8> ClsExprs; llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy); QualType argType = Context->getPointerType(Context->CharTy);
ClsExprs.push_back(StringLiteral::Create(*Context, ClsExprs.push_back(StringLiteral::Create(*Context,
SuperDecl->getIdentifier()->getName(), SuperDecl->getIdentifier()->getNameStart(),
SuperDecl->getIdentifier()->getLength(), SuperDecl->getIdentifier()->getLength(),
false, argType, SourceLocation())); false, argType, SourceLocation()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl, CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,

View File

@ -72,7 +72,8 @@ Entity EntityGetter::VisitNamedDecl(NamedDecl *D) {
if (IdentifierInfo *II = LocalName.getAsIdentifierInfo()) { if (IdentifierInfo *II = LocalName.getAsIdentifierInfo()) {
IdentifierInfo *GlobII = IdentifierInfo *GlobII =
&ProgImpl.getIdents().get(II->getName(), II->getName() + II->getLength()); &ProgImpl.getIdents().get(II->getNameStart(),
II->getNameStart() + II->getLength());
GlobName = DeclarationName(GlobII); GlobName = DeclarationName(GlobII);
} else { } else {
Selector LocalSel = LocalName.getObjCSelector(); Selector LocalSel = LocalName.getObjCSelector();
@ -139,8 +140,9 @@ Decl *EntityImpl::getDecl(ASTContext &AST) {
DeclarationName LocalName; DeclarationName LocalName;
if (IdentifierInfo *GlobII = Name.getAsIdentifierInfo()) { if (IdentifierInfo *GlobII = Name.getAsIdentifierInfo()) {
IdentifierInfo &II = AST.Idents.get(GlobII->getName(), IdentifierInfo &II =
GlobII->getName() + GlobII->getLength()); AST.Idents.get(GlobII->getNameStart(),
GlobII->getNameStart() + GlobII->getLength());
LocalName = DeclarationName(&II); LocalName = DeclarationName(&II);
} else { } else {
Selector GlobSel = Name.getObjCSelector(); Selector GlobSel = Name.getObjCSelector();

View File

@ -29,8 +29,9 @@ Selector GlobalSelector::getSelector(ASTContext &AST) const {
for (unsigned i = 0, e = GlobSel.isUnarySelector() ? 1 : GlobSel.getNumArgs(); for (unsigned i = 0, e = GlobSel.isUnarySelector() ? 1 : GlobSel.getNumArgs();
i != e; ++i) { i != e; ++i) {
IdentifierInfo *GlobII = GlobSel.getIdentifierInfoForSlot(i); IdentifierInfo *GlobII = GlobSel.getIdentifierInfoForSlot(i);
IdentifierInfo *II = &AST.Idents.get(GlobII->getName(), IdentifierInfo *II =
GlobII->getName() + GlobII->getLength()); &AST.Idents.get(GlobII->getNameStart(),
GlobII->getNameStart() + GlobII->getLength());
Ids.push_back(II); Ids.push_back(II);
} }
@ -57,8 +58,9 @@ GlobalSelector GlobalSelector::get(Selector Sel, Program &Prog) {
for (unsigned i = 0, e = Sel.isUnarySelector() ? 1 : Sel.getNumArgs(); for (unsigned i = 0, e = Sel.isUnarySelector() ? 1 : Sel.getNumArgs();
i != e; ++i) { i != e; ++i) {
IdentifierInfo *II = Sel.getIdentifierInfoForSlot(i); IdentifierInfo *II = Sel.getIdentifierInfoForSlot(i);
IdentifierInfo *GlobII = &ProgImpl.getIdents().get(II->getName(), IdentifierInfo *GlobII =
II->getName() + II->getLength()); &ProgImpl.getIdents().get(II->getNameStart(),
II->getNameStart() + II->getLength());
Ids.push_back(GlobII); Ids.push_back(GlobII);
} }

View File

@ -1071,7 +1071,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
// we allow macros that expand to nothing after the filename, because this // we allow macros that expand to nothing after the filename, because this
// falls into the category of "#include pp-tokens new-line" specified in // falls into the category of "#include pp-tokens new-line" specified in
// C99 6.10.2p4. // C99 6.10.2p4.
CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getName(), true); CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getNameStart(), true);
// Check that we don't have infinite #include recursion. // Check that we don't have infinite #include recursion.
if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) { if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) {

View File

@ -96,14 +96,6 @@ LexNextToken:
//===--------------------------------------==// //===--------------------------------------==//
// Process the token. // Process the token.
//===--------------------------------------==// //===--------------------------------------==//
#if 0
SourceManager& SM = PP->getSourceManager();
llvm::errs() << SM.getFileEntryForID(FileID)->getName()
<< ':' << SM.getLogicalLineNumber(Tok.getLocation())
<< ':' << SM.getLogicalColumnNumber(Tok.getLocation())
<< '\n';
#endif
if (TKind == tok::eof) { if (TKind == tok::eof) {
// Save the end-of-file token. // Save the end-of-file token.
EofToken = Tok; EofToken = Tok;
@ -563,7 +555,7 @@ IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
// Store the new IdentifierInfo in the cache. // Store the new IdentifierInfo in the cache.
PerIDCache[PersistentID] = II; PerIDCache[PersistentID] = II;
assert(II->getName() && II->getName()[0] != '\0'); assert(II->getNameStart() && II->getNameStart()[0] != '\0');
return II; return II;
} }

View File

@ -234,7 +234,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
// If this token is an identifier, just return the string from the identifier // If this token is an identifier, just return the string from the identifier
// table, which is very quick. // table, which is very quick.
if (const IdentifierInfo *II = Tok.getIdentifierInfo()) { if (const IdentifierInfo *II = Tok.getIdentifierInfo()) {
Buffer = II->getName(); Buffer = II->getNameStart();
return II->getLength(); return II->getLength();
} }

View File

@ -95,7 +95,7 @@ TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
static char GetFirstChar(Preprocessor &PP, const Token &Tok) { static char GetFirstChar(Preprocessor &PP, const Token &Tok) {
if (IdentifierInfo *II = Tok.getIdentifierInfo()) { if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
// Avoid spelling identifiers, the most common form of token. // Avoid spelling identifiers, the most common form of token.
return II->getName()[0]; return II->getNameStart()[0];
} else if (!Tok.needsCleaning()) { } else if (!Tok.needsCleaning()) {
if (Tok.isLiteral() && Tok.getLiteralData()) { if (Tok.isLiteral() && Tok.getLiteralData()) {
return *Tok.getLiteralData(); return *Tok.getLiteralData();

View File

@ -428,7 +428,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
return; return;
} }
if (II->getName()[0] == 's') { if (II->getNameStart()[0] == 's') {
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter); DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
DS.setSetterName(Tok.getIdentifierInfo()); DS.setSetterName(Tok.getIdentifierInfo());
ConsumeToken(); // consume method name ConsumeToken(); // consume method name

View File

@ -235,8 +235,10 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
// Filter out names reserved for the implementation (C99 7.1.3, // Filter out names reserved for the implementation (C99 7.1.3,
// C++ [lib.global.names]). Users don't need to see those. // C++ [lib.global.names]). Users don't need to see those.
//
// FIXME: Add predicate for this.
if (Id->getLength() >= 2) { if (Id->getLength() >= 2) {
const char *Name = Id->getName(); const char *Name = Id->getNameStart();
if (Name[0] == '_' && if (Name[0] == '_' &&
(Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z'))) (Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z')))
return; return;

View File

@ -1885,7 +1885,7 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
const ExtVectorType *vecType = baseType->getAs<ExtVectorType>(); const ExtVectorType *vecType = baseType->getAs<ExtVectorType>();
// The vector accessor can't exceed the number of elements. // The vector accessor can't exceed the number of elements.
const char *compStr = CompName->getName(); const char *compStr = CompName->getNameStart();
// This flag determines whether or not the component is one of the four // This flag determines whether or not the component is one of the four
// special names that indicate a subset of exactly half the elements are // special names that indicate a subset of exactly half the elements are
@ -1922,7 +1922,7 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
// Ensure no component accessor exceeds the width of the vector type it // Ensure no component accessor exceeds the width of the vector type it
// operates on. // operates on.
if (!HalvingSwizzle) { if (!HalvingSwizzle) {
compStr = CompName->getName(); compStr = CompName->getNameStart();
if (HexSwizzle) if (HexSwizzle)
compStr++; compStr++;

View File

@ -473,7 +473,7 @@ const char *clang_getDeclSpelling(CXDecl AnonDecl)
return OMD->getSelector().getAsString().c_str(); return OMD->getSelector().getAsString().c_str();
} }
if (ND->getIdentifier()) if (ND->getIdentifier())
return ND->getIdentifier()->getName(); return ND->getIdentifier()->getNameStart();
else else
return ""; return "";
} }
@ -513,22 +513,22 @@ const char *clang_getCursorSpelling(CXCursor C)
{ {
ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND); ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing interface decl"); assert(OID && "clang_getCursorLine(): Missing interface decl");
return OID->getSuperClass()->getIdentifier()->getName(); return OID->getSuperClass()->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCClassRef: case CXCursor_ObjCClassRef:
{ {
if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND)) { if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND)) {
return OID->getIdentifier()->getName(); return OID->getIdentifier()->getNameStart();
} }
ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND); ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing category decl"); assert(OID && "clang_getCursorLine(): Missing category decl");
return OID->getClassInterface()->getIdentifier()->getName(); return OID->getClassInterface()->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCProtocolRef: case CXCursor_ObjCProtocolRef:
{ {
ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND); ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing protocol decl"); assert(OID && "clang_getCursorLine(): Missing protocol decl");
return OID->getIdentifier()->getName(); return OID->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCSelectorRef: case CXCursor_ObjCSelectorRef:
{ {
@ -544,7 +544,7 @@ const char *clang_getCursorSpelling(CXCursor C)
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>( DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
static_cast<Stmt *>(C.stmt)); static_cast<Stmt *>(C.stmt));
assert(DRE && "clang_getCursorLine(): Missing decl ref expr"); assert(DRE && "clang_getCursorLine(): Missing decl ref expr");
return DRE->getDecl()->getIdentifier()->getName(); return DRE->getDecl()->getIdentifier()->getNameStart();
} }
default: default:
return "<not implemented>"; return "<not implemented>";