]> granicus.if.org Git - clang/commitdiff
See through UsingDecls in more places.
authorAnders Carlsson <andersca@mac.com>
Fri, 26 Jun 2009 05:26:50 +0000 (05:26 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 26 Jun 2009 05:26:50 +0000 (05:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74269 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/AST/DeclBase.cpp
lib/Sema/SemaLookup.cpp

index 4e006c08ea45787287ef0f286c92689f79740c80..a2fe24e83105bb27ccaf2ae7df1b9ec31e8fc099 100644 (file)
@@ -1101,17 +1101,25 @@ class UsingDecl : public NamedDecl {
 public:
   /// \brief Returns the source range that covers the nested-name-specifier
   /// preceding the namespace name.
-  SourceRange getNestedNameRange() { return(NestedNameRange); }
+  SourceRange getNestedNameRange() { return NestedNameRange; }
+  
   /// \brief Returns the source location of the target declaration name.
-  SourceLocation getTargetNameLocation() { return(TargetNameLocation); }
+  SourceLocation getTargetNameLocation() { return TargetNameLocation; }
+  
   /// \brief Returns the source location of the "using" location itself.
-  SourceLocation getUsingLocation() { return(UsingLocation); }
+  SourceLocation getUsingLocation() { return UsingLocation; }
+  
   /// \brief getTargetDecl - Returns target specified by using-decl.
-  NamedDecl *getTargetDecl() { return(TargetDecl); }
+  NamedDecl *getTargetDecl() { return TargetDecl; }
+  const NamedDecl *getTargetDecl() const { return TargetDecl; }
+  
   /// \brief Get target nested name declaration.
-  NestedNameSpecifier* getTargetNestedNameDecl() { return(TargetNestedNameDecl); }
+  NestedNameSpecifier* getTargetNestedNameDecl() { 
+    return TargetNestedNameDecl; 
+  }
+  
   /// isTypeName - Return true if using decl had 'typename'.
-  bool isTypeName() const { return(IsTypeName); }
+  bool isTypeName() const { return IsTypeName; }
 
   static UsingDecl *Create(ASTContext &C, DeclContext *DC,
       SourceLocation L, SourceRange NNR, SourceLocation TargetNL,
index 93bee84cff540cbe058cc1ea3a45d9ecf2d5850d..5815d820aef609ccbda77470ed40231a28968098 100644 (file)
@@ -97,6 +97,9 @@ bool Decl::isTemplateParameterPack() const {
 }
 
 bool Decl::isFunctionOrFunctionTemplate() const {
+  if (const UsingDecl *UD = dyn_cast<UsingDecl>(this))
+    return UD->getTargetDecl()->isFunctionOrFunctionTemplate();
+    
   return isa<FunctionDecl>(this) || isa<FunctionTemplateDecl>(this);
 }
 
index e1c6302fcc164c72e9195f68c870bbeeb0e73aa2..d76761c696351f199468364a5b83181e5d9c4bad 100644 (file)
@@ -139,16 +139,24 @@ MaybeConstructOverloadSet(ASTContext &Context,
         // nothing to leak.
         Ovl = OverloadedFunctionDecl::Create(Context, (*I)->getDeclContext(),
                                              (*I)->getDeclName());
-        if (isa<FunctionDecl>(*I))
-          Ovl->addOverload(cast<FunctionDecl>(*I));
+        NamedDecl *ND = (*I);
+        if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
+          ND = UD->getTargetDecl();
+
+        if (isa<FunctionDecl>(ND))
+          Ovl->addOverload(cast<FunctionDecl>(ND));
         else
-          Ovl->addOverload(cast<FunctionTemplateDecl>(*I));
+          Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
       }
 
-      if (isa<FunctionDecl>(*Last))
-        Ovl->addOverload(cast<FunctionDecl>(*Last));
+      NamedDecl *ND = (*Last);
+      if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
+        ND = UD->getTargetDecl();
+      
+      if (isa<FunctionDecl>(ND))
+        Ovl->addOverload(cast<FunctionDecl>(ND));
       else
-        Ovl->addOverload(cast<FunctionTemplateDecl>(*Last));
+        Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
     }
     
     // If we had more than one function, we built an overload