[cfe-commits] r91906 - in /cfe/trunk/lib/Sema: SemaExpr.cpp SemaInit.cpp SemaInit.h
Douglas Gregor
dgregor at apple.com
Tue Dec 22 08:09:06 PST 2009
Author: dgregor
Date: Tue Dec 22 10:09:06 2009
New Revision: 91906
URL: http://llvm.org/viewvc/llvm-project?rev=91906&view=rev
Log:
Switch parameter-passing for calls via function pointers (where we
don't have a FunctionDecl) over to InitializationSequence.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaInit.h
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=91906&r1=91905&r2=91906&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 22 10:09:06 2009
@@ -3181,21 +3181,22 @@
<< Arg->getSourceRange()))
return true;
- // Pass the argument.
- if (FDecl && i < FDecl->getNumParams()) {
- ParmVarDecl *Param = FDecl->getParamDecl(i);
- InitializedEntity Entity =InitializedEntity::InitializeParameter(Param);
- OwningExprResult ArgE = PerformCopyInitialization(Entity,
- SourceLocation(),
- Owned(Arg));
- if (ArgE.isInvalid())
- return true;
+ // Pass the argument
+ ParmVarDecl *Param = 0;
+ if (FDecl && i < FDecl->getNumParams())
+ Param = FDecl->getParamDecl(i);
- Arg = ArgE.takeAs<Expr>();
- } else {
- if (PerformCopyInitialization(Arg, ProtoArgType, AA_Passing))
- return true;
- }
+
+ InitializedEntity Entity =
+ Param? InitializedEntity::InitializeParameter(Param)
+ : InitializedEntity::InitializeParameter(ProtoArgType);
+ OwningExprResult ArgE = PerformCopyInitialization(Entity,
+ SourceLocation(),
+ Owned(Arg));
+ if (ArgE.isInvalid())
+ return true;
+
+ Arg = ArgE.takeAs<Expr>();
if (!ProtoArgType->isReferenceType())
Arg = MaybeBindToTemporary(Arg).takeAs<Expr>();
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=91906&r1=91905&r2=91906&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Dec 22 10:09:06 2009
@@ -1807,8 +1807,12 @@
DeclarationName InitializedEntity::getName() const {
switch (getKind()) {
- case EK_Variable:
case EK_Parameter:
+ if (!VariableOrMember)
+ return DeclarationName();
+ // Fall through
+
+ case EK_Variable:
case EK_Member:
return VariableOrMember->getDeclName();
Modified: cfe/trunk/lib/Sema/SemaInit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.h?rev=91906&r1=91905&r2=91906&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.h (original)
+++ cfe/trunk/lib/Sema/SemaInit.h Tue Dec 22 10:09:06 2009
@@ -105,8 +105,9 @@
: Kind(EK_Parameter), Parent(0), Type(Parm->getType()),
VariableOrMember(reinterpret_cast<DeclaratorDecl*>(Parm)) { }
- /// \brief Create the initialization entity for the result of a function,
- /// throwing an object, or performing an explicit cast.
+ /// \brief Create the initialization entity for the result of a
+ /// function, throwing an object, performing an explicit cast, or
+ /// initializing a parameter for which there is no declaration.
InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type)
: Kind(Kind), Parent(0), Type(Type), Location(Loc.getRawEncoding()) { }
@@ -130,6 +131,12 @@
return InitializedEntity(Parm);
}
+ /// \brief Create the initialization entity for a parameter that is
+ /// only known by its type.
+ static InitializedEntity InitializeParameter(QualType Type) {
+ return InitializedEntity(EK_Parameter, SourceLocation(), Type);
+ }
+
/// \brief Create the initialization entity for the result of a function.
static InitializedEntity InitializeResult(SourceLocation ReturnLoc,
QualType Type) {
More information about the cfe-commits
mailing list