Skip ParenType on function instantiations.

llvm-svn: 121720
This commit is contained in:
Abramo Bagnara 2010-12-13 22:27:55 +00:00
parent 9c00c014ab
commit a44c902d2f
3 changed files with 13 additions and 3 deletions

View File

@ -115,6 +115,8 @@ public:
/// \brief Skips past any qualifiers, if this is qualified.
UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
TypeLoc IgnoreParens() const;
/// \brief Initializes this to state that every location in this
/// type is the given location.
///

View File

@ -229,3 +229,11 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
return TST_unspecified;
}
TypeLoc TypeLoc::IgnoreParens() const {
TypeLoc TL = *this;
while (ParenTypeLoc* PTL = dyn_cast<ParenTypeLoc>(&TL))
TL = PTL->getInnerLoc();
return TL;
}

View File

@ -1908,10 +1908,10 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
if (NewTInfo != OldTInfo) {
// Get parameters from the new type info.
TypeLoc OldTL = OldTInfo->getTypeLoc();
TypeLoc OldTL = OldTInfo->getTypeLoc().IgnoreParens();
if (FunctionProtoTypeLoc *OldProtoLoc
= dyn_cast<FunctionProtoTypeLoc>(&OldTL)) {
TypeLoc NewTL = NewTInfo->getTypeLoc();
TypeLoc NewTL = NewTInfo->getTypeLoc().IgnoreParens();
FunctionProtoTypeLoc *NewProtoLoc = cast<FunctionProtoTypeLoc>(&NewTL);
assert(NewProtoLoc && "Missing prototype?");
for (unsigned i = 0, i_end = NewProtoLoc->getNumArgs(); i != i_end; ++i) {
@ -1926,7 +1926,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
// The function type itself was not dependent and therefore no
// substitution occurred. However, we still need to instantiate
// the function parameters themselves.
TypeLoc OldTL = OldTInfo->getTypeLoc();
TypeLoc OldTL = OldTInfo->getTypeLoc().IgnoreParens();
if (FunctionProtoTypeLoc *OldProtoLoc
= dyn_cast<FunctionProtoTypeLoc>(&OldTL)) {
for (unsigned i = 0, i_end = OldProtoLoc->getNumArgs(); i != i_end; ++i) {