Added support to the expression parser for locating
externally-defined functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@106606 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangASTSource.cpp b/source/Expression/ClangASTSource.cpp
index 3bae8b3..3c18b70 100644
--- a/source/Expression/ClangASTSource.cpp
+++ b/source/Expression/ClangASTSource.cpp
@@ -97,3 +97,50 @@
     
     return Decl;
 }
+
+clang::NamedDecl *NameSearchContext::AddFunDecl(void *type) {
+    clang::FunctionDecl *Decl = FunctionDecl::Create(ASTSource.Context,
+                                                     const_cast<DeclContext*>(DC),
+                                                     SourceLocation(),
+                                                     Name.getAsIdentifierInfo(),
+                                                     QualType::getFromOpaquePtr(type),
+                                                     NULL,
+                                                     FunctionDecl::Static,
+                                                     FunctionDecl::Static,
+                                                     false,
+                                                     true);
+    
+    QualType QT = QualType::getFromOpaquePtr(type);
+    clang::Type *T = QT.getTypePtr();
+    
+    if (T->isFunctionProtoType())
+    {
+        FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(T);
+        
+        unsigned NumArgs = FPT->getNumArgs();
+        unsigned ArgIndex;
+        
+        ParmVarDecl *ParmVarDecls[NumArgs];
+        
+        for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex)
+        {
+            QualType ArgQT = FPT->getArgType(ArgIndex);
+            
+            ParmVarDecls[ArgIndex] = ParmVarDecl::Create(ASTSource.Context,
+                                                         const_cast<DeclContext*>(DC),
+                                                         SourceLocation(),
+                                                         NULL,
+                                                         ArgQT,
+                                                         NULL,
+                                                         ParmVarDecl::Static,
+                                                         ParmVarDecl::Static,
+                                                         NULL);
+        }
+        
+        Decl->setParams(ParmVarDecls, NumArgs);
+    }
+    
+    Decls.push_back(Decl);
+    
+    return Decl;
+}