[cfe-commits] r74269 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclBase.cpp lib/Sema/SemaLookup.cpp

Anders Carlsson andersca at mac.com
Thu Jun 25 22:26:50 PDT 2009


Author: andersca
Date: Fri Jun 26 00:26:50 2009
New Revision: 74269

URL: http://llvm.org/viewvc/llvm-project?rev=74269&view=rev
Log:
See through UsingDecls in more places.

Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=74269&r1=74268&r2=74269&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Jun 26 00:26:50 2009
@@ -1101,17 +1101,25 @@
 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,

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=74269&r1=74268&r2=74269&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Jun 26 00:26:50 2009
@@ -97,6 +97,9 @@
 }
 
 bool Decl::isFunctionOrFunctionTemplate() const {
+  if (const UsingDecl *UD = dyn_cast<UsingDecl>(this))
+    return UD->getTargetDecl()->isFunctionOrFunctionTemplate();
+    
   return isa<FunctionDecl>(this) || isa<FunctionTemplateDecl>(this);
 }
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=74269&r1=74268&r2=74269&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Jun 26 00:26:50 2009
@@ -139,16 +139,24 @@
         // 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





More information about the cfe-commits mailing list