Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Basic/XRayLists.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- XRayLists.cpp - XRay automatic-attribution ------------------------===//
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
#include "clang/Basic/XRayLists.h"
13
14
using namespace clang;
15
16
XRayFunctionFilter::XRayFunctionFilter(
17
    ArrayRef<std::string> AlwaysInstrumentPaths,
18
    ArrayRef<std::string> NeverInstrumentPaths,
19
    ArrayRef<std::string> AttrListPaths, SourceManager &SM)
20
    : AlwaysInstrument(
21
          llvm::SpecialCaseList::createOrDie(AlwaysInstrumentPaths)),
22
      NeverInstrument(llvm::SpecialCaseList::createOrDie(NeverInstrumentPaths)),
23
41.7k
      AttrList(llvm::SpecialCaseList::createOrDie(AttrListPaths)), SM(SM) {}
24
25
XRayFunctionFilter::ImbueAttribute
26
9
XRayFunctionFilter::shouldImbueFunction(StringRef FunctionName) const {
27
9
  // First apply the always instrument list, than if it isn't an "always" see
28
9
  // whether it's treated as a "never" instrument function.
29
9
  // TODO: Remove these as they're deprecated; use the AttrList exclusively.
30
9
  if (AlwaysInstrument->inSection("xray_always_instrument", "fun", FunctionName,
31
9
                                  "arg1") ||
32
9
      
AttrList->inSection("always", "fun", FunctionName, "arg1")8
)
33
2
    return ImbueAttribute::ALWAYS_ARG1;
34
7
  if (AlwaysInstrument->inSection("xray_always_instrument", "fun",
35
7
                                  FunctionName) ||
36
7
      AttrList->inSection("always", "fun", FunctionName))
37
1
    return ImbueAttribute::ALWAYS;
38
6
39
6
  if (NeverInstrument->inSection("xray_never_instrument", "fun",
40
6
                                 FunctionName) ||
41
6
      AttrList->inSection("never", "fun", FunctionName))
42
1
    return ImbueAttribute::NEVER;
43
5
44
5
  return ImbueAttribute::NONE;
45
5
}
46
47
XRayFunctionFilter::ImbueAttribute
48
XRayFunctionFilter::shouldImbueFunctionsInFile(StringRef Filename,
49
17
                                               StringRef Category) const {
50
17
  if (AlwaysInstrument->inSection("xray_always_instrument", "src", Filename,
51
17
                                  Category) ||
52
17
      
AttrList->inSection("always", "src", Filename, Category)15
)
53
4
    return ImbueAttribute::ALWAYS;
54
13
  if (NeverInstrument->inSection("xray_never_instrument", "src", Filename,
55
13
                                 Category) ||
56
13
      
AttrList->inSection("never", "src", Filename, Category)11
)
57
4
    return ImbueAttribute::NEVER;
58
9
  return ImbueAttribute::NONE;
59
9
}
60
61
XRayFunctionFilter::ImbueAttribute
62
XRayFunctionFilter::shouldImbueLocation(SourceLocation Loc,
63
17
                                        StringRef Category) const {
64
17
  if (!Loc.isValid())
65
0
    return ImbueAttribute::NONE;
66
17
  return this->shouldImbueFunctionsInFile(SM.getFilename(SM.getFileLoc(Loc)),
67
17
                                          Category);
68
17
}