aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-23 21:45:46 +0000
committerChris Lattner <sabre@nondot.org>2008-11-23 21:45:46 +0000
commit08631c5fa053867146b5ee8be658c229f6bf127c (patch)
treee1938ec851a8ca72ade476e71a10797fdacd12a7 /lib/Sema/SemaDecl.cpp
parent011bb4edf731d529da1cbf71c7c2696aaf5a054f (diff)
Convert IdentifierInfo's to be printed the same as DeclarationNames
with implicit quotes around them. This has a bunch of follow-on effects and requires tweaking to a whole lot of code. This causes a regression in two tests (xfailed) by causing it to emit things like: Line 10: duplicate interface declaration for category 'MyClass1' ('Category1') instead of: Line 10: duplicate interface declaration for category 'MyClass1(Category1)' I will fix this in a follow-up commit. As part of this, I had to start switching stuff to use ->getDeclName() instead of Decl::getName() for consistency. This is good, but I was planning to do this as an independent patch. There will be several follow-on patches to clean up some of the mess, but this patch is already too big. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59917 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index fba9f3328b..c3b130255b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -325,7 +325,7 @@ TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
TypedefDecl *Old = dyn_cast<TypedefDecl>(OldD);
if (!Old) {
Diag(New->getLocation(), diag::err_redefinition_different_kind)
- << New->getName();
+ << New->getDeclName();
Diag(OldD->getLocation(), diag::err_previous_definition);
return New;
}
@@ -364,7 +364,7 @@ TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
return New;
}
- Diag(New->getLocation(), diag::err_redefinition) << New->getName();
+ Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName();
Diag(Old->getLocation(), diag::err_previous_definition);
return New;
}
@@ -418,7 +418,7 @@ Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, bool &Redeclaration) {
FunctionDecl *Old = dyn_cast<FunctionDecl>(OldD);
if (!Old) {
Diag(New->getLocation(), diag::err_redefinition_different_kind)
- << New->getName();
+ << New->getDeclName();
Diag(OldD->getLocation(), diag::err_previous_definition);
return New;
}
@@ -537,7 +537,7 @@ void Sema::CheckForFileScopedRedefinitions(Scope *S, VarDecl *VD) {
OldDecl->getStorageClass() != VarDecl::PrivateExtern &&
VD->getStorageClass() != VarDecl::Extern &&
VD->getStorageClass() != VarDecl::PrivateExtern) {
- Diag(VD->getLocation(), diag::err_redefinition) << VD->getName();
+ Diag(VD->getLocation(), diag::err_redefinition) << VD->getDeclName();
Diag(OldDecl->getLocation(), diag::err_previous_definition);
}
}
@@ -557,7 +557,7 @@ VarDecl *Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
VarDecl *Old = dyn_cast<VarDecl>(OldD);
if (!Old) {
Diag(New->getLocation(), diag::err_redefinition_different_kind)
- << New->getName();
+ << New->getDeclName();
Diag(OldD->getLocation(), diag::err_previous_definition);
return New;
}
@@ -568,7 +568,7 @@ VarDecl *Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
QualType OldCType = Context.getCanonicalType(Old->getType());
QualType NewCType = Context.getCanonicalType(New->getType());
if (OldCType != NewCType && !Context.typesAreCompatible(OldCType, NewCType)) {
- Diag(New->getLocation(), diag::err_redefinition) << New->getName();
+ Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName();
Diag(Old->getLocation(), diag::err_previous_definition);
return New;
}
@@ -589,7 +589,7 @@ VarDecl *Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
}
// Variables with external linkage are analyzed in FinalizeDeclaratorGroup.
if (New->getStorageClass() != VarDecl::Extern && !New->isFileVarDecl()) {
- Diag(New->getLocation(), diag::err_redefinition) << New->getName();
+ Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName();
Diag(Old->getLocation(), diag::err_previous_definition);
}
return New;
@@ -849,7 +849,7 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
if (PrevDecl == 0) {
// No previous declaration in the qualifying scope.
Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member)
- << Name.getAsString() << D.getCXXScopeSpec().getRange();
+ << Name << D.getCXXScopeSpec().getRange();
} else if (!CurContext->Encloses(DC)) {
// The qualifying scope doesn't enclose the original declaration.
// Emit diagnostic based on current scope.
@@ -1987,8 +1987,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
IdentifierInfo *II = D.getIdentifier();
if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
if (S->isDeclScope(PrevDecl)) {
- Diag(D.getIdentifierLoc(), diag::err_param_redefinition)
- << cast<NamedDecl>(PrevDecl)->getName();
+ Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
// Recover by removing the name
II = 0;
@@ -2076,7 +2075,7 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
// See if this is a redefinition.
const FunctionDecl *Definition;
if (FD->getBody(Definition)) {
- Diag(FD->getLocation(), diag::err_redefinition) << FD->getName();
+ Diag(FD->getLocation(), diag::err_redefinition) << FD->getDeclName();
Diag(Definition->getLocation(), diag::err_previous_definition);
}
@@ -2804,7 +2803,7 @@ void Sema::ActOnFields(Scope* S,
/// A field cannot be an Objective-c object
if (FDTy->isObjCInterfaceType()) {
Diag(FD->getLocation(), diag::err_statically_allocated_object)
- << FD->getName();
+ << FD->getDeclName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;