[cfe-commits] [PATCH] Preserve FunctionType::ExtInfo across template instantiation
Eli Friedman
eli.friedman at gmail.com
Sat Jul 24 16:55:08 PDT 2010
Patch attached. Fixes Sema handling of constructs like
"template<typename T> void p(T (__attribute__((fastcall)) *f)(void));"
Does this look like the right thing to do?
-Eli
-------------- next part --------------
Index: lib/Sema/Sema.h
===================================================================
--- lib/Sema/Sema.h (revision 109357)
+++ lib/Sema/Sema.h (working copy)
@@ -273,6 +273,9 @@
/// of 0 indicates default alignment.
void *PackContext; // Really a "PragmaPackStack*"
+ /// VisContext - Manages the stack for #pragma GCC visibility.
+ void *VisContext; // Really a "PragmaVisStack*"
+
/// \brief Stack containing information about each of the nested function,
/// block, and method scopes that are currently active.
llvm::SmallVector<FunctionScopeInfo *, 4> FunctionScopes;
@@ -742,7 +745,8 @@
QualType BuildFunctionType(QualType T,
QualType *ParamTypes, unsigned NumParamTypes,
bool Variadic, unsigned Quals,
- SourceLocation Loc, DeclarationName Entity);
+ SourceLocation Loc, DeclarationName Entity,
+ const FunctionType::ExtInfo &Info);
QualType BuildMemberPointerType(QualType T, QualType Class,
SourceLocation Loc,
DeclarationName Entity);
@@ -4140,6 +4144,10 @@
SourceLocation LParenLoc,
SourceLocation RParenLoc);
+ /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
+ virtual void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
+ SourceLocation PragmaLoc);
+
NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
@@ -4162,6 +4170,13 @@
/// FreePackedContext - Deallocate and null out PackContext.
void FreePackedContext();
+ /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
+ /// add an appropriate visibility attribute.
+ void AddPushedVisibilityAttribute(Decl *RD);
+
+ /// FreeVisContext - Deallocate and null out VisContext.
+ void FreeVisContext();
+
/// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E);
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h (revision 109357)
+++ lib/Sema/TreeTransform.h (working copy)
@@ -468,7 +468,8 @@
QualType RebuildFunctionProtoType(QualType T,
QualType *ParamTypes,
unsigned NumParamTypes,
- bool Variadic, unsigned Quals);
+ bool Variadic, unsigned Quals,
+ const FunctionType::ExtInfo &Info);
/// \brief Build a new unprototyped function type.
QualType RebuildFunctionNoProtoType(QualType ResultType);
@@ -2932,7 +2933,8 @@
ParamTypes.data(),
ParamTypes.size(),
T->isVariadic(),
- T->getTypeQuals());
+ T->getTypeQuals(),
+ T->getExtInfo());
if (Result.isNull())
return QualType();
}
@@ -6258,7 +6260,8 @@
ParamTypes.data(),
ParamTypes.size(),
BD->isVariadic(),
- 0);
+ 0,
+ BExprFunctionType->getExtInfo());
CurBlock->FunctionType = FunctionType;
return SemaRef.ActOnBlockStmtExpr(CaretLoc, move(Body), /*Scope=*/0);
@@ -6435,11 +6438,13 @@
QualType *ParamTypes,
unsigned NumParamTypes,
bool Variadic,
- unsigned Quals) {
+ unsigned Quals,
+ const FunctionType::ExtInfo &Info) {
return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
Quals,
getDerived().getBaseLocation(),
- getDerived().getBaseEntity());
+ getDerived().getBaseEntity(),
+ Info);
}
template<typename Derived>
Index: lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- lib/Sema/SemaTemplateDeduction.cpp (revision 109357)
+++ lib/Sema/SemaTemplateDeduction.cpp (working copy)
@@ -1245,7 +1245,8 @@
Proto->isVariadic(),
Proto->getTypeQuals(),
Function->getLocation(),
- Function->getDeclName());
+ Function->getDeclName(),
+ Proto->getExtInfo());
if (FunctionType->isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
}
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp (revision 109357)
+++ lib/Sema/SemaType.cpp (working copy)
@@ -810,7 +810,8 @@
QualType *ParamTypes,
unsigned NumParamTypes,
bool Variadic, unsigned Quals,
- SourceLocation Loc, DeclarationName Entity) {
+ SourceLocation Loc, DeclarationName Entity,
+ const FunctionType::ExtInfo &Info) {
if (T->isArrayType() || T->isFunctionType()) {
Diag(Loc, diag::err_func_returning_array_function)
<< T->isFunctionType() << T;
@@ -832,8 +833,7 @@
return QualType();
return Context.getFunctionType(T, ParamTypes, NumParamTypes, Variadic,
- Quals, false, false, 0, 0,
- FunctionType::ExtInfo());
+ Quals, false, false, 0, 0, Info);
}
/// \brief Build a member pointer type \c T Class::*.
More information about the cfe-commits
mailing list