1eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala/* 2eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * Copyright 2015, The Android Open Source Project 3eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * 4eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * Licensed under the Apache License, Version 2.0 (the "License"); 5eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * you may not use this file except in compliance with the License. 6eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * You may obtain a copy of the License at 7eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * 8eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * http://www.apache.org/licenses/LICENSE-2.0 9eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * 10eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * Unless required by applicable law or agreed to in writing, software 11eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * distributed under the License is distributed on an "AS IS" BASIS, 12eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * See the License for the specific language governing permissions and 14eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala * limitations under the License. 15eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala */ 16eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 17eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_SPECIAL_FUNC_H_ 18eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_SPECIAL_FUNC_H_ 19eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 20eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#include "llvm/ADT/StringRef.h" 21eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 22eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#include "clang/AST/Decl.h" 23eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 24eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#include "slang_rs_context.h" 25eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 26eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walanamespace slang { 27eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 28eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walanamespace RSSpecialFunc { 29eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 30eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walainline bool isInitRSFunc(const clang::FunctionDecl *FD) { 31eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala if (!FD) { 32eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala return false; 33eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala } 34eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala const llvm::StringRef Name = FD->getName(); 35eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala static llvm::StringRef FuncInit("init"); 36eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala return Name.equals(FuncInit); 37eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala} 38eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 39eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walainline bool isDtorRSFunc(const clang::FunctionDecl *FD) { 40eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala if (!FD) { 41eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala return false; 42eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala } 43eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala const llvm::StringRef Name = FD->getName(); 44eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala static llvm::StringRef FuncDtor(".rs.dtor"); 45eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala return Name.equals(FuncDtor); 46eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala} 47eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 48eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walabool isGraphicsRootRSFunc(unsigned int targetAPI, 49eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala const clang::FunctionDecl *FD); 50eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 51eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walainline bool isSpecialRSFunc(unsigned int targetAPI, 52eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala const clang::FunctionDecl *FD) { 53eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala return isGraphicsRootRSFunc(targetAPI, FD) || isInitRSFunc(FD) || 54eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala isDtorRSFunc(FD); 55eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala} 56eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 57eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Walabool validateSpecialFuncDecl(unsigned int targetAPI, 58eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala slang::RSContext *Context, 59eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala const clang::FunctionDecl *FD); 60eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 61eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala} // namespace RSSpecialFunc 62eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 63eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala} // namespace slang 64eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala 65eae0b7ad0195360b0afc37d51553f2917f1aa365Matt Wala#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_SPECIAL_FUNC_H 66