[cfe-commits] r59609 - in /cfe/trunk/lib/Sema: Sema.h SemaCXXScopeSpec.cpp SemaChecking.cpp SemaDecl.cpp SemaDeclAttr.cpp SemaDeclCXX.cpp SemaDeclObjC.cpp SemaExpr.cpp SemaExprObjC.cpp SemaStmt.cpp
Chris Lattner
sabre at nondot.org
Wed Nov 19 00:23:27 PST 2008
Author: lattner
Date: Wed Nov 19 02:23:25 2008
New Revision: 59609
URL: http://llvm.org/viewvc/llvm-project?rev=59609&view=rev
Log:
stop calling II::getName() unnecesarily in sema
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Nov 19 02:23:25 2008
@@ -88,6 +88,7 @@
/// push - Push the current alignment onto the stack, optionally
/// using the given \arg Name for the record, if non-zero,
void push(IdentifierInfo *Name) {
+ // FIXME: Why does this push 'Name' as an std::string??
Stack.push_back(std::make_pair(Alignment,
std::string(Name ? Name->getName() : "")));
}
Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Wed Nov 19 02:23:25 2008
@@ -98,9 +98,9 @@
DiagID = diag::err_undeclared_var_use;
if (DC)
- Diag(IdLoc, DiagID, II.getName(), SS.getRange());
+ Diag(IdLoc, DiagID) << &II << SS.getRange();
else
- Diag(IdLoc, DiagID, II.getName());
+ Diag(IdLoc, DiagID) << &II;
return 0;
}
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Nov 19 02:23:25 2008
@@ -716,9 +716,8 @@
// Perform checking for returned stack addresses.
if (lhsType->isPointerType() || lhsType->isBlockPointerType()) {
if (DeclRefExpr *DR = EvalAddr(RetValExp))
- Diag(DR->getLocStart(), diag::warn_ret_stack_addr,
- DR->getDecl()->getIdentifier()->getName(),
- RetValExp->getSourceRange());
+ Diag(DR->getLocStart(), diag::warn_ret_stack_addr)
+ << DR->getDecl()->getIdentifier() << RetValExp->getSourceRange();
// Skip over implicit cast expressions when checking for block expressions.
if (ImplicitCastExpr *IcExpr =
@@ -734,7 +733,7 @@
// Check for a reference to the stack
if (DeclRefExpr *DR = EvalVal(RetValExp))
Diag(DR->getLocStart(), diag::warn_ret_stack_ref)
- << DR->getDecl()->getIdentifier()->getName()
+ << DR->getDecl()->getIdentifier()
<< RetValExp->getSourceRange();
}
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 19 02:23:25 2008
@@ -1127,8 +1127,8 @@
CheckExtraCXXDefaultArguments(D);
if (R.getTypePtr()->isObjCInterfaceType()) {
- Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object,
- D.getIdentifier()->getName());
+ Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object)
+ << D.getIdentifier();
InvalidDecl = true;
}
@@ -2032,8 +2032,8 @@
if (!FTI.hasPrototype) {
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
if (FTI.ArgInfo[i].Param == 0) {
- Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared,
- FTI.ArgInfo[i].Ident->getName());
+ Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
+ << FTI.ArgInfo[i].Ident;
// Implicitly declare the argument as type 'int' for lack of a better
// type.
DeclSpec DS;
@@ -2129,9 +2129,9 @@
IdentifierInfo &II, Scope *S) {
// Extension in C99. Legal in C90, but warn about it.
if (getLangOptions().C99)
- Diag(Loc, diag::ext_implicit_function_decl, II.getName());
+ Diag(Loc, diag::ext_implicit_function_decl) << &II;
else
- Diag(Loc, diag::warn_implicit_function_decl, II.getName());
+ Diag(Loc, diag::warn_implicit_function_decl) << &II;
// FIXME: handle stuff like:
// void foo() { extern float X(); }
@@ -2222,8 +2222,7 @@
// A tag 'foo::bar' must already exist.
if (PrevDecl == 0) {
- Diag(NameLoc, diag::err_not_tag_in_scope, Name->getName(),
- SS.getRange());
+ Diag(NameLoc, diag::err_not_tag_in_scope) << Name << SS.getRange();
Name = 0;
goto CreateNewDecl;
}
@@ -2245,7 +2244,7 @@
// Make sure that this wasn't declared as an enum and now used as a
// struct or something similar.
if (PrevTagDecl->getTagKind() != Kind) {
- Diag(KWLoc, diag::err_use_with_wrong_tag, Name->getName());
+ Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
Diag(PrevDecl->getLocation(), diag::err_previous_use);
// Recover by making this an anonymous redefinition.
Name = 0;
@@ -2257,7 +2256,7 @@
// Diagnose attempts to redefine a tag.
if (PrevTagDecl->isDefinition()) {
- Diag(NameLoc, diag::err_redefinition, Name->getName());
+ Diag(NameLoc, diag::err_redefinition) << Name;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
// If this is a redefinition, recover by making this struct be
// anonymous, which will make any later references get the previous
@@ -2279,7 +2278,7 @@
if (isDeclInScope(PrevDecl, DC, S)) {
// The tag name clashes with a namespace name, issue an error and
// recover by making this tag be anonymous.
- Diag(NameLoc, diag::err_redefinition_different_kind, Name->getName());
+ Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
Name = 0;
}
@@ -2359,8 +2358,7 @@
// A tag 'foo::bar' must already exist.
if (PrevDecl == 0) {
- Diag(NameLoc, diag::err_not_tag_in_scope, Name->getName(),
- SS.getRange());
+ Diag(NameLoc, diag::err_not_tag_in_scope) << Name << SS.getRange();
Name = 0;
goto CreateNewDecl;
}
@@ -2383,7 +2381,7 @@
// Make sure that this wasn't declared as an enum and now used as a
// struct or something similar.
if (PrevTagDecl->getTagKind() != Kind) {
- Diag(KWLoc, diag::err_use_with_wrong_tag, Name->getName());
+ Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
Diag(PrevDecl->getLocation(), diag::err_previous_use);
// Recover by making this an anonymous redefinition.
Name = 0;
@@ -2403,7 +2401,7 @@
// Diagnose attempts to redefine a tag.
if (RecordDecl* DefRecord =
cast<RecordDecl>(PrevTagDecl)->getDefinition(Context)) {
- Diag(NameLoc, diag::err_redefinition, Name->getName());
+ Diag(NameLoc, diag::err_redefinition) << Name;
Diag(DefRecord->getLocation(), diag::err_previous_definition);
// If this is a redefinition, recover by making this struct be
// anonymous, which will make any later references get the previous
@@ -2430,7 +2428,7 @@
if (isDeclInScope(PrevDecl, DC, S)) {
// The tag name clashes with a namespace name, issue an error and
// recover by making this tag be anonymous.
- Diag(NameLoc, diag::err_redefinition_different_kind, Name->getName());
+ Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
Name = 0;
}
@@ -2520,7 +2518,7 @@
// Check that ClassName is a valid class
ObjCInterfaceDecl *Class = getObjCInterfaceDecl(ClassName);
if (!Class) {
- Diag(DeclStart, diag::err_undef_interface, ClassName->getName());
+ Diag(DeclStart, diag::err_undef_interface) << ClassName;
return;
}
// Collect the instance variables
@@ -2802,7 +2800,7 @@
if (IdentifierInfo *II = FD->getIdentifier()) {
// Detect duplicate member names.
if (!FieldIDs.insert(II)) {
- Diag(FD->getLocation(), diag::err_duplicate_member, II->getName());
+ Diag(FD->getLocation(), diag::err_duplicate_member) << II;
// Find the previous decl.
SourceLocation PrevLoc;
for (unsigned i = 0; ; ++i) {
@@ -2867,9 +2865,9 @@
"Received TagDecl when not in C++!");
if (!isa<TagDecl>(PrevDecl) && isDeclInScope(PrevDecl, CurContext, S)) {
if (isa<EnumConstantDecl>(PrevDecl))
- Diag(IdLoc, diag::err_redefinition_of_enumerator, Id->getName());
+ Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
else
- Diag(IdLoc, diag::err_redefinition, Id->getName());
+ Diag(IdLoc, diag::err_redefinition) << Id;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
delete Val;
return 0;
@@ -2885,8 +2883,7 @@
// C99 6.7.2.2p2: Make sure we have an integer constant expression.
SourceLocation ExpLoc;
if (!Val->isIntegerConstantExpr(EnumVal, Context, &ExpLoc)) {
- Diag(ExpLoc, diag::err_enum_value_not_integer_constant_expr,
- Id->getName());
+ Diag(ExpLoc, diag::err_enum_value_not_integer_constant_expr) << Id;
delete Val;
Val = 0; // Just forget about it.
} else {
@@ -3200,7 +3197,7 @@
// Otherwise, find the named record.
for (unsigned i = Stack.size(); i != 0; ) {
--i;
- if (strcmp(Stack[i].second.c_str(), Name->getName()) == 0) {
+ if (Name->isName(Stack[i].second.c_str())) {
// Found it, pop up to and including this record.
Alignment = Stack[i].first;
Stack.erase(Stack.begin() + i, Stack.end());
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Nov 19 02:23:25 2008
@@ -145,7 +145,7 @@
QualType curType = tDecl->getUnderlyingType();
// check the attribute arguments.
if (Attr.getNumArgs() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
Expr *sizeExpr = static_cast<Expr *>(Attr.getArg(0));
@@ -200,7 +200,7 @@
// Check the attribute arugments.
if (Attr.getNumArgs() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
Expr *sizeExpr = static_cast<Expr *>(Attr.getArg(0));
@@ -262,7 +262,7 @@
static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() > 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -274,18 +274,17 @@
if (!FD->getType()->isIncompleteType() &&
S.Context.getTypeAlign(FD->getType()) <= 8)
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
- << Attr.getName()->getName() << FD->getType().getAsString();
+ << Attr.getName() << FD->getType().getAsString();
else
FD->addAttr(new PackedAttr(1));
} else
- S.Diag(Attr.getLoc(), diag::warn_attribute_ignored)
- << Attr.getName()->getName();
+ S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
}
static void HandleIBOutletAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() > 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -370,7 +369,7 @@
static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
@@ -380,7 +379,7 @@
if (Str == 0 || Str->isWide()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
- << "alias" << "1";
+ << "alias" << 1;
return;
}
@@ -396,7 +395,7 @@
Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -406,7 +405,7 @@
static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -422,7 +421,7 @@
static void HandleUnusedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -449,7 +448,7 @@
llvm::APSInt Idx(32);
if (!E->isIntegerConstantExpr(Idx, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "constructor" << "1" << E->getSourceRange();
+ << "constructor" << 1 << E->getSourceRange();
return;
}
priority = Idx.getZExtValue();
@@ -479,7 +478,7 @@
llvm::APSInt Idx(32);
if (!E->isIntegerConstantExpr(Idx, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "destructor" << "1" << E->getSourceRange();
+ << "destructor" << 1 << E->getSourceRange();
return;
}
priority = Idx.getZExtValue();
@@ -497,7 +496,7 @@
static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -507,7 +506,7 @@
static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
@@ -517,7 +516,7 @@
if (Str == 0 || Str->isWide()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
- << "visibility" << "1";
+ << "visibility" << 1;
return;
}
@@ -545,28 +544,24 @@
static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) {
if (!Attr.getParameterName()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
- << "objc_gc" << "1";
+ << "objc_gc" << 1;
return;
}
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
- << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
- const char *TypeStr = Attr.getParameterName()->getName();
- unsigned TypeLen = Attr.getParameterName()->getLength();
ObjCGCAttr::GCAttrTypes type;
-
- if (TypeLen == 4 && !memcmp(TypeStr, "weak", 4))
+ if (Attr.getParameterName()->isName("weak"))
type = ObjCGCAttr::Weak;
- else if (TypeLen == 6 && !memcmp(TypeStr, "strong", 6))
+ else if (Attr.getParameterName()->isName("strong"))
type = ObjCGCAttr::Strong;
else {
S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
- << "objc_gc" << TypeStr;
+ << "objc_gc" << Attr.getParameterName();
return;
}
@@ -576,25 +571,21 @@
static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) {
if (!Attr.getParameterName()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
- << "blocks" << "1";
+ << "blocks" << 1;
return;
}
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
- << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
- const char *TypeStr = Attr.getParameterName()->getName();
- unsigned TypeLen = Attr.getParameterName()->getLength();
BlocksAttr::BlocksAttrTypes type;
-
- if (TypeLen == 5 && !memcmp(TypeStr, "byref", 5))
+ if (Attr.getParameterName()->isName("byref"))
type = BlocksAttr::ByRef;
else {
S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
- << "blocks" << TypeStr;
+ << "blocks" << Attr.getParameterName();
return;
}
@@ -615,7 +606,7 @@
llvm::APSInt Idx(32);
if (!E->isIntegerConstantExpr(Idx, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "sentinel" << "1" << E->getSourceRange();
+ << "sentinel" << 1 << E->getSourceRange();
return;
}
sentinel = Idx.getZExtValue();
@@ -633,7 +624,7 @@
llvm::APSInt Idx(32);
if (!E->isIntegerConstantExpr(Idx, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "sentinel" << "2" << E->getSourceRange();
+ << "sentinel" << 2 << E->getSourceRange();
return;
}
nullPos = Idx.getZExtValue();
@@ -670,7 +661,7 @@
static void HandleWeakAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -680,7 +671,7 @@
static void HandleDLLImportAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -690,7 +681,7 @@
static void HandleDLLExportAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -700,7 +691,7 @@
static void HandleStdCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -710,7 +701,7 @@
static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -720,7 +711,7 @@
static void HandleNothrowAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -730,7 +721,7 @@
static void HandleConstAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -740,7 +731,7 @@
static void HandlePureAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -753,12 +744,12 @@
if (!Attr.getParameterName()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
- << "format" << "1";
+ << "format" << 1;
return;
}
if (Attr.getNumArgs() != 2) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "3";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 3;
return;
}
@@ -812,13 +803,13 @@
llvm::APSInt Idx(32);
if (!IdxExpr->isIntegerConstantExpr(Idx, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "format" << "2" << IdxExpr->getSourceRange();
+ << "format" << 2 << IdxExpr->getSourceRange();
return;
}
if (Idx.getZExtValue() < FirstIdx || Idx.getZExtValue() > NumArgs) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
- << "format" << "2" << IdxExpr->getSourceRange();
+ << "format" << 2 << IdxExpr->getSourceRange();
return;
}
@@ -858,7 +849,7 @@
llvm::APSInt FirstArg(32);
if (!FirstArgExpr->isIntegerConstantExpr(FirstArg, S.Context)) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_int)
- << "format" << "3" << FirstArgExpr->getSourceRange();
+ << "format" << 3 << FirstArgExpr->getSourceRange();
return;
}
@@ -872,8 +863,8 @@
}
}
- // strftime requires FirstArg to be 0 because it doesn't read from any variable
- // the input is just the current time + the format string
+ // strftime requires FirstArg to be 0 because it doesn't read from any
+ // variable the input is just the current time + the format string.
if (is_strftime) {
if (FirstArg != 0) {
S.Diag(Attr.getLoc(), diag::err_format_strftime_third_parameter)
@@ -883,7 +874,7 @@
// if 0 it disables parameter checking (to use with e.g. va_list)
} else if (FirstArg != 0 && FirstArg != NumArgs) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
- << "format" << "3" << FirstArgExpr->getSourceRange();
+ << "format" << 3 << FirstArgExpr->getSourceRange();
return;
}
@@ -895,7 +886,7 @@
Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -932,7 +923,7 @@
static void HandleAnnotateAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
Expr *argExpr = static_cast<Expr *>(Attr.getArg(0));
@@ -951,7 +942,7 @@
static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() > 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "1";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
@@ -986,7 +977,7 @@
// Check that there aren't any arguments
if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0";
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
@@ -1048,10 +1039,10 @@
QualType NewTy;
switch (DestWidth) {
case 0:
- S.Diag(Attr.getLoc(), diag::err_unknown_machine_mode) << Name->getName();
+ S.Diag(Attr.getLoc(), diag::err_unknown_machine_mode) << Name;
return;
default:
- S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) <<Name->getName();
+ S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name;
return;
case 8:
assert(IntegerMode);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Nov 19 02:23:25 2008
@@ -644,13 +644,13 @@
// It didn't name a member, so see if it names a class.
TypeTy *BaseTy = isTypeName(*MemberOrBase, S, 0/*SS*/);
if (!BaseTy)
- return Diag(IdLoc, diag::err_mem_init_not_member_or_class,
- MemberOrBase->getName(), SourceRange(IdLoc, RParenLoc));
+ return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
+ << MemberOrBase << SourceRange(IdLoc, RParenLoc);
QualType BaseType = Context.getTypeDeclType((TypeDecl *)BaseTy);
if (!BaseType->isRecordType())
- return Diag(IdLoc, diag::err_base_init_does_not_name_class,
- BaseType.getAsString(), SourceRange(IdLoc, RParenLoc));
+ return Diag(IdLoc, diag::err_base_init_does_not_name_class)
+ << BaseType.getAsString() << SourceRange(IdLoc, RParenLoc);
// C++ [class.base.init]p2:
// [...] Unless the mem-initializer-id names a nonstatic data
@@ -697,8 +697,8 @@
// a direct non-virtual base class and an inherited virtual base
// class, the mem-initializer is ill-formed.
if (DirectBaseSpec && VirtualBaseSpec)
- return Diag(IdLoc, diag::err_base_init_direct_and_virtual,
- MemberOrBase->getName(), SourceRange(IdLoc, RParenLoc));
+ return Diag(IdLoc, diag::err_base_init_direct_and_virtual)
+ << MemberOrBase << SourceRange(IdLoc, RParenLoc);
return new CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, NumArgs);
}
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Nov 19 02:23:25 2008
@@ -67,8 +67,7 @@
// Check for another declaration kind with the same name.
Decl *PrevDecl = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
- Diag(ClassLoc, diag::err_redefinition_different_kind)
- << ClassName->getName();
+ Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
}
@@ -100,20 +99,20 @@
// Check if a different kind of symbol declared in this scope.
PrevDecl = LookupDecl(SuperName, Decl::IDNS_Ordinary, TUScope);
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
- Diag(SuperLoc, diag::err_redefinition_different_kind)
- << SuperName->getName();
+ Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
}
else {
// Check that super class is previously defined
SuperClassEntry = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
-
- if (!SuperClassEntry || SuperClassEntry->isForwardDecl()) {
+
+ if (!SuperClassEntry)
Diag(SuperLoc, diag::err_undef_superclass)
- << (SuperClassEntry ? SuperClassEntry->getName()
- : SuperName->getName())
- << ClassName->getName() << SourceRange(AtInterfaceLoc, ClassLoc);
- }
+ << SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
+ else if (SuperClassEntry->isForwardDecl())
+ Diag(SuperLoc, diag::err_undef_superclass)
+ << SuperClassEntry->getName() << ClassName
+ << SourceRange(AtInterfaceLoc, ClassLoc);
}
IDecl->setSuperClass(SuperClassEntry);
IDecl->setSuperClassLoc(SuperLoc);
@@ -147,8 +146,7 @@
Diag(ADecl->getLocation(), diag::warn_previous_declaration);
}
else {
- Diag(AliasLocation, diag::err_conflicting_aliasing_type)
- << AliasName->getName();
+ Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
Diag(ADecl->getLocation(), diag::err_previous_declaration);
}
return 0;
@@ -157,7 +155,7 @@
Decl *CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
ObjCInterfaceDecl *CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDeclU);
if (CDecl == 0) {
- Diag(ClassLocation, diag::warn_undef_interface) << ClassName->getName();
+ Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
if (CDeclU)
Diag(CDeclU->getLocation(), diag::warn_previous_declaration);
return 0;
@@ -189,8 +187,7 @@
if (PDecl) {
// Protocol already seen. Better be a forward protocol declaration
if (!PDecl->isForwardDecl()) {
- Diag(ProtocolLoc, diag::err_duplicate_protocol_def)
- << ProtocolName->getName();
+ Diag(ProtocolLoc, diag::err_duplicate_protocol_def) << ProtocolName;
// Just return the protocol we already had.
// FIXME: don't leak the objects passed in!
return PDecl;
@@ -226,7 +223,7 @@
ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first];
if (!PDecl) {
Diag(ProtocolId[i].second, diag::err_undeclared_protocol)
- << ProtocolId[i].first->getName();
+ << ProtocolId[i].first;
continue;
}
@@ -234,7 +231,7 @@
// case, do it.
if (WarnOnDeclarations && PDecl->isForwardDecl())
Diag(ProtocolId[i].second, diag::warn_undef_protocolref)
- << ProtocolId[i].first->getName();
+ << ProtocolId[i].first;
Protocols.push_back(PDecl);
}
}
@@ -400,7 +397,7 @@
/// Check that class of this category is already completely declared.
if (!IDecl || IDecl->isForwardDecl())
- Diag(ClassLoc, diag::err_undef_interface) << ClassName->getName();
+ Diag(ClassLoc, diag::err_undef_interface) << ClassName;
else {
/// Check for duplicate interface declaration for this category
ObjCCategoryDecl *CDeclChain;
@@ -408,7 +405,7 @@
CDeclChain = CDeclChain->getNextClassCategory()) {
if (CategoryName && CDeclChain->getIdentifier() == CategoryName) {
Diag(CategoryLoc, diag::warn_dup_category_def)
- << ClassName->getName() << CategoryName->getName();
+ << ClassName << CategoryName;
break;
}
}
@@ -437,7 +434,7 @@
ObjCCategoryImplDecl::Create(Context, AtCatImplLoc, CatName, IDecl);
/// Check that class of this category is already completely declared.
if (!IDecl || IDecl->isForwardDecl())
- Diag(ClassLoc, diag::err_undef_interface) << ClassName->getName();
+ Diag(ClassLoc, diag::err_undef_interface) << ClassName;
/// TODO: Check that CatName, category name, is not used in another
// implementation.
@@ -456,15 +453,14 @@
// Check for another declaration kind with the same name.
Decl *PrevDecl = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
- Diag(ClassLoc, diag::err_redefinition_different_kind,
- ClassName->getName());
+ Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
}
else {
// Is there an interface declaration of this class; if not, warn!
IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!IDecl)
- Diag(ClassLoc, diag::warn_undef_interface) << ClassName->getName();
+ Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
}
// Check that super class name is valid class name
@@ -473,20 +469,19 @@
// Check if a different kind of symbol declared in this scope.
PrevDecl = LookupDecl(SuperClassname, Decl::IDNS_Ordinary, TUScope);
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
- Diag(SuperClassLoc, diag::err_redefinition_different_kind,
- SuperClassname->getName());
+ Diag(SuperClassLoc, diag::err_redefinition_different_kind)
+ << SuperClassname;
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
- }
- else {
+ } else {
SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!SDecl)
- Diag(SuperClassLoc, diag::err_undef_superclass,
- SuperClassname->getName(), ClassName->getName());
+ Diag(SuperClassLoc, diag::err_undef_superclass)
+ << SuperClassname << ClassName;
else if (IDecl && IDecl->getSuperClass() != SDecl) {
// This implementation and its interface do not have the same
// super class.
- Diag(SuperClassLoc, diag::err_conflicting_super_class,
- SDecl->getName());
+ Diag(SuperClassLoc, diag::err_conflicting_super_class)
+ << SDecl->getName();
Diag(SDecl->getLocation(), diag::err_previous_definition);
}
}
@@ -518,7 +513,7 @@
// Check that there is no duplicate implementation of this class.
if (ObjCImplementations[ClassName])
// FIXME: Don't leak everything!
- Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName());
+ Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
else // add it to the list.
ObjCImplementations[ClassName] = IMPDecl;
return IMPDecl;
@@ -558,17 +553,17 @@
if (Context.getCanonicalType(ImplIvar->getType()) !=
Context.getCanonicalType(ClsIvar->getType())) {
Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type)
- << ImplIvar->getIdentifier()->getName();
+ << ImplIvar->getIdentifier();
Diag(ClsIvar->getLocation(), diag::err_previous_definition)
- << ClsIvar->getIdentifier()->getName();
+ << ClsIvar->getIdentifier();
}
// TODO: Two mismatched (unequal width) Ivar bitfields should be diagnosed
// as error.
else if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) {
Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name)
- << ImplIvar->getIdentifier()->getName();
+ << ImplIvar->getIdentifier();
Diag(ClsIvar->getLocation(), diag::err_previous_definition)
- << ClsIvar->getIdentifier()->getName();
+ << ClsIvar->getIdentifier();
return;
}
--numIvars;
@@ -729,8 +724,7 @@
// FIXME: Make an extension?
TypedefDecl *TDD = dyn_cast<TypedefDecl>(PrevDecl);
if (!TDD || !isa<ObjCInterfaceType>(TDD->getUnderlyingType())) {
- Diag(AtClassLoc, diag::err_redefinition_different_kind,
- IdentList[i]->getName());
+ Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
Diag(PrevDecl->getLocation(), diag::err_previous_definition);
}
}
@@ -1314,8 +1308,7 @@
// Check that this is a previously declared 'ivar' in 'IDecl' interface
Ivar = IDecl->FindIvarDeclaration(PropertyIvar);
if (!Ivar) {
- Diag(PropertyLoc, diag::error_missing_property_ivar_decl,
- PropertyId->getName());
+ Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;
return 0;
}
QualType PropType = Context.getCanonicalType(property->getType());
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 19 02:23:25 2008
@@ -900,7 +900,7 @@
// vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
// vec4.hi, vec4.lo, vec4.e, and vec4.o all return vec2.
unsigned CompSize = SpecialComponent ? vecType->getNumElements() / 2
- : strlen(CompName.getName());
+ : CompName.getLength();
if (CompSize == 1)
return vecType->getElementType();
@@ -921,16 +921,11 @@
// live?
static IdentifierInfo *constructSetterName(IdentifierTable &Idents,
const IdentifierInfo *Name) {
- unsigned N = Name->getLength();
- char *SelectorName = new char[3 + N];
- memcpy(SelectorName, "set", 3);
- memcpy(&SelectorName[3], Name->getName(), N);
+ llvm::SmallString<100> SelectorName;
+ SelectorName += "set";
+ SelectorName.append(Name->getName(), Name->getName()+Name->getLength());
SelectorName[3] = toupper(SelectorName[3]);
-
- IdentifierInfo *Setter =
- &Idents.get(SelectorName, &SelectorName[3 + N]);
- delete[] SelectorName;
- return Setter;
+ return &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]);
}
Action::ExprResult Sema::
@@ -967,7 +962,7 @@
FieldDecl *MemberDecl = RDecl->getMember(&Member);
if (!MemberDecl)
return Diag(MemberLoc, diag::err_typecheck_no_member)
- << Member.getName() << BaseExpr->getSourceRange();
+ << &Member << BaseExpr->getSourceRange();
// Figure out the type of the member; see C99 6.5.2.3p3
// FIXME: Handle address space modifiers
@@ -991,7 +986,7 @@
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
OpKind == tok::arrow);
return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
- << IFTy->getDecl()->getName() << Member.getName()
+ << IFTy->getDecl()->getName() << &Member
<< BaseExpr->getSourceRange();
}
@@ -3106,9 +3101,8 @@
RecordDecl *RD = RC->getDecl();
FieldDecl *MemberDecl = RD->getMember(OC.U.IdentInfo);
if (!MemberDecl)
- return Diag(BuiltinLoc, diag::err_typecheck_no_member,
- OC.U.IdentInfo->getName(),
- SourceRange(OC.LocStart, OC.LocEnd));
+ return Diag(BuiltinLoc, diag::err_typecheck_no_member)
+ << OC.U.IdentInfo << SourceRange(OC.LocStart, OC.LocEnd);
// FIXME: C++: Verify that MemberDecl isn't a static field.
// FIXME: Verify that MemberDecl isn't a bitfield.
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Nov 19 02:23:25 2008
@@ -96,7 +96,7 @@
SourceLocation RParenLoc) {
ObjCProtocolDecl* PDecl = ObjCProtocols[ProtocolId];
if (!PDecl) {
- Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId->getName();
+ Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
return true;
}
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=59609&r1=59608&r2=59609&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Nov 19 02:23:25 2008
@@ -756,26 +756,30 @@
getCurMethodDecl()->getResultType();
if (FnRetType->isVoidType()) {
- if (RetValExp) // C99 6.8.6.4p1 (ext_ since GCC warns)
- Diag(ReturnLoc, diag::ext_return_has_expr,
- ( getCurFunctionDecl() ?
- getCurFunctionDecl()->getIdentifier()->getName() :
- getCurMethodDecl()->getSelector().getName() ),
- RetValExp->getSourceRange());
- return new ReturnStmt(ReturnLoc, RetValExp);
- } else {
- if (!RetValExp) {
- const char *funcName =
- getCurFunctionDecl() ?
- getCurFunctionDecl()->getIdentifier()->getName() :
- getCurMethodDecl()->getSelector().getName().c_str();
- if (getLangOptions().C99) // C99 6.8.6.4p1 (ext_ since GCC warns)
- Diag(ReturnLoc, diag::ext_return_missing_expr, funcName);
- else // C90 6.6.6.4p4
- Diag(ReturnLoc, diag::warn_return_missing_expr, funcName);
- return new ReturnStmt(ReturnLoc, (Expr*)0);
+ if (RetValExp) {// C99 6.8.6.4p1 (ext_ since GCC warns)
+ if (FunctionDecl *FD = getCurFunctionDecl())
+ Diag(ReturnLoc, diag::ext_return_has_expr)
+ << FD->getIdentifier() << RetValExp->getSourceRange();
+ else
+ Diag(ReturnLoc, diag::ext_return_has_expr)
+ << getCurMethodDecl()->getSelector().getName()
+ << RetValExp->getSourceRange();
}
+ return new ReturnStmt(ReturnLoc, RetValExp);
}
+
+ if (!RetValExp) {
+ unsigned DiagID = diag::warn_return_missing_expr; // C90 6.6.6.4p4
+ // C99 6.8.6.4p1 (ext_ since GCC warns)
+ if (getLangOptions().C99) DiagID = diag::ext_return_missing_expr;
+
+ if (FunctionDecl *FD = getCurFunctionDecl())
+ Diag(ReturnLoc, DiagID) << FD->getIdentifier();
+ else
+ Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getSelector().getName();
+ return new ReturnStmt(ReturnLoc, (Expr*)0);
+ }
+
// we have a non-void function with an expression, continue checking
QualType RetValType = RetValExp->getType();
More information about the cfe-commits
mailing list