• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2016 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ABI_DIFF_WRAPPERS_H_
16 #define ABI_DIFF_WRAPPERS_H_
17 
18 #include "repr/abi_diff_helpers.h"
19 #include "repr/ir_representation.h"
20 
21 
22 namespace header_checker {
23 namespace diff {
24 
25 
26 using repr::AbiDiffHelper;
27 using repr::AbiElementMap;
28 using repr::DiffStatus;
29 
30 
31 template <typename T, typename F>
IgnoreSymbol(const T * element,const std::set<std::string> & ignored_symbols,F func)32 static bool IgnoreSymbol(const T *element,
33                          const std::set<std::string> &ignored_symbols,
34                          F func) {
35   return ignored_symbols.find(func(element)) != ignored_symbols.end();
36 }
37 
38 template <typename T>
39 class DiffWrapper : public AbiDiffHelper {
40  public:
DiffWrapper(const T * oldp,const T * newp,repr::IRDiffDumper * ir_diff_dumper,const AbiElementMap<const repr::TypeIR * > & old_types,const AbiElementMap<const repr::TypeIR * > & new_types,const repr::DiffPolicyOptions & diff_policy_options,std::set<std::string> * type_cache)41   DiffWrapper(const T *oldp, const T *newp,
42               repr::IRDiffDumper *ir_diff_dumper,
43               const AbiElementMap<const repr::TypeIR *> &old_types,
44               const AbiElementMap<const repr::TypeIR *> &new_types,
45               const repr::DiffPolicyOptions &diff_policy_options,
46               std::set<std::string> *type_cache)
47       : AbiDiffHelper(old_types, new_types, diff_policy_options, type_cache,
48                       ir_diff_dumper),
49         oldp_(oldp), newp_(newp) {}
50 
51   bool DumpDiff(repr::IRDiffDumper::DiffKind diff_kind);
52 
53  private:
54   const T *oldp_;
55   const T *newp_;
56 };
57 
58 
59 }  // namespace diff
60 }  // namespace header_checker
61 
62 
63 #endif  // ABI_DIFF_WRAPPERS_H_
64