Skip ParenType on function instantiations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121720 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index 1ec0e6c..6f2e705 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -115,6 +115,8 @@
/// \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.
///
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp
index 0ba9fc0..c987b9b 100644
--- a/lib/AST/TypeLoc.cpp
+++ b/lib/AST/TypeLoc.cpp
@@ -229,3 +229,11 @@
return TST_unspecified;
}
+
+TypeLoc TypeLoc::IgnoreParens() const {
+ TypeLoc TL = *this;
+ while (ParenTypeLoc* PTL = dyn_cast<ParenTypeLoc>(&TL))
+ TL = PTL->getInnerLoc();
+ return TL;
+}
+
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index f98efec..31692fc 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1908,10 +1908,10 @@
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 @@
// 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) {