From 3fbe68a4ec20fec25f8a40191437bbc02d00f591 Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Wed, 17 Nov 2010 17:28:59 -0800 Subject: Turn on support for exporting non-static funcs. Bug: 2932253 Change-Id: Ice5422b4a3d78f8c2973e1af6c8abea30fa74bb6 --- slang_rs_context.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'slang_rs_context.cpp') diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp index cd4c8af..9edf383 100644 --- a/slang_rs_context.cpp +++ b/slang_rs_context.cpp @@ -51,7 +51,7 @@ RSContext::RSContext(clang::Preprocessor &PP, mTargetData(NULL), mLLVMContext(llvm::getGlobalContext()), mExportAllNonStaticVars(true), - mExportAllNonStaticFuncs(false), + mExportAllNonStaticFuncs(true), mLicenseNote(NULL) { // For #pragma rs export_var PP.AddPragmaHandler( @@ -105,11 +105,18 @@ bool RSContext::processExportVar(const clang::VarDecl *VD) { return true; } +static bool isSpecialRSFunc(const llvm::StringRef& Name) { + static llvm::StringRef FuncInit("init"); + static llvm::StringRef FuncRoot("root"); + return Name.equals(FuncInit) || Name.equals(FuncRoot); +} + bool RSContext::processExportFunc(const clang::FunctionDecl *FD) { assert(!FD->getName().empty() && "Function name should not be empty"); - if (!FD->isThisDeclarationADefinition()) - return false; + if (!FD->isThisDeclarationADefinition()) { + return true; + } if (FD->getStorageClass() != clang::SC_None) { fprintf(stderr, "RSContext::processExportFunc : cannot export extern or " @@ -117,6 +124,11 @@ bool RSContext::processExportFunc(const clang::FunctionDecl *FD) { return false; } + // Do not reflect specialized RS functions like init/root. + if (isSpecialRSFunc(FD->getName())) { + return true; + } + RSExportFunc *EF = RSExportFunc::Create(this, FD); if (EF == NULL) return false; -- cgit v1.2.3