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 "clang/Basic/SourceManager.h"
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/SpecialCaseList.h"
21 #include <memory>
22 
23 namespace clang {
24 
25 class XRayFunctionFilter {
26   std::unique_ptr<llvm::SpecialCaseList> AlwaysInstrument;
27   std::unique_ptr<llvm::SpecialCaseList> NeverInstrument;
28   std::unique_ptr<llvm::SpecialCaseList> AttrList;
29   SourceManager &SM;
30 
31 public:
32   XRayFunctionFilter(ArrayRef<std::string> AlwaysInstrumentPaths,
33                      ArrayRef<std::string> NeverInstrumentPaths,
34                      ArrayRef<std::string> AttrListPaths, SourceManager &SM);
35 
36   enum class ImbueAttribute {
37     NONE,
38     ALWAYS,
39     NEVER,
40     ALWAYS_ARG1,
41   };
42 
43   ImbueAttribute shouldImbueFunction(StringRef FunctionName) const;
44 
45   ImbueAttribute
46   shouldImbueFunctionsInFile(StringRef Filename,
47                              StringRef Category = StringRef()) const;
48 
49   ImbueAttribute shouldImbueLocation(SourceLocation Loc,
50                                      StringRef Category = StringRef()) const;
51 };
52 
53 } // namespace clang
54 
55 #endif
56