]> granicus.if.org Git - clang/commitdiff
Skip ParenType on function instantiations.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Mon, 13 Dec 2010 22:27:55 +0000 (22:27 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Mon, 13 Dec 2010 22:27:55 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121720 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/TypeLoc.h
lib/AST/TypeLoc.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp

index 1ec0e6cdd1f0b486279250aa20bea3edf204829d..6f2e705953d965d005b75b825692bffc66726709 100644 (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.
   ///
index 0ba9fc00876e6dcadd65ad516aae1783a34c79ac..c987b9bb9b1f7ab0f4f0f71781f07f4fde308087 100644 (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;
+}
+
index f98efec5ed255e8f5abe56898e9a207ef6953e0c..31692fc1f2ee97e2f30235195e6771f88d534a11 100644 (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) {