1 | //===--- XRayLists.h - XRay automatic attribution ---------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // User-provided filters for always/never XRay instrumenting certain functions. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | #ifndef LLVM_CLANG_BASIC_XRAYLISTS_H |
13 | #define LLVM_CLANG_BASIC_XRAYLISTS_H |
14 | |
15 | #include "clang/Basic/LLVM.h" |
16 | #include "clang/Basic/SourceLocation.h" |
17 | #include "llvm/ADT/ArrayRef.h" |
18 | #include "llvm/ADT/StringRef.h" |
19 | #include <memory> |
20 | |
21 | namespace llvm { |
22 | class SpecialCaseList; |
23 | } |
24 | |
25 | namespace clang { |
26 | |
27 | class SourceManager; |
28 | |
29 | class XRayFunctionFilter { |
30 | std::unique_ptr<llvm::SpecialCaseList> AlwaysInstrument; |
31 | std::unique_ptr<llvm::SpecialCaseList> NeverInstrument; |
32 | std::unique_ptr<llvm::SpecialCaseList> AttrList; |
33 | SourceManager &SM; |
34 | |
35 | public: |
36 | XRayFunctionFilter(ArrayRef<std::string> AlwaysInstrumentPaths, |
37 | ArrayRef<std::string> NeverInstrumentPaths, |
38 | ArrayRef<std::string> AttrListPaths, SourceManager &SM); |
39 | ~XRayFunctionFilter(); |
40 | |
41 | enum class ImbueAttribute { |
42 | NONE, |
43 | ALWAYS, |
44 | NEVER, |
45 | ALWAYS_ARG1, |
46 | }; |
47 | |
48 | ImbueAttribute shouldImbueFunction(StringRef FunctionName) const; |
49 | |
50 | ImbueAttribute |
51 | shouldImbueFunctionsInFile(StringRef Filename, |
52 | StringRef Category = StringRef()) const; |
53 | |
54 | ImbueAttribute shouldImbueLocation(SourceLocation Loc, |
55 | StringRef Category = StringRef()) const; |
56 | }; |
57 | |
58 | } // namespace clang |
59 | |
60 | #endif |
61 | |