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