[cfe-commits] r45915 - /cfe/trunk/Sema/SemaExpr.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 12 11:32:28 PST 2008
Author: lattner
Date: Sat Jan 12 13:32:28 2008
New Revision: 45915
URL: http://llvm.org/viewvc/llvm-project?rev=45915&view=rev
Log:
allow __func__ in objc methods.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=45915&r1=45914&r2=45915&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sat Jan 12 13:32:28 2008
@@ -122,16 +122,20 @@
}
// Verify that this is in a function context.
- if (CurFunctionDecl == 0)
+ if (CurFunctionDecl == 0 && CurMethodDecl == 0)
return Diag(Loc, diag::err_predef_outside_function);
// Pre-defined identifiers are of type char[x], where x is the length of the
// string.
- llvm::APSInt Length(32);
- Length = CurFunctionDecl->getIdentifier()->getLength() + 1;
+ unsigned Length;
+ if (CurFunctionDecl)
+ Length = CurFunctionDecl->getIdentifier()->getLength();
+ else
+ Length = CurMethodDecl->getSelector().getName().size();
+ llvm::APInt LengthI(32, Length + 1);
QualType ResTy = Context.CharTy.getQualifiedType(QualType::Const);
- ResTy = Context.getConstantArrayType(ResTy, Length, ArrayType::Normal, 0);
+ ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal, 0);
return new PreDefinedExpr(Loc, ResTy, IT);
}
More information about the cfe-commits
mailing list