summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/BlackList.h
blob: ee18a985674db390e4ba218b3375e36a082fa8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//===-- BlackList.h - blacklist for sanitizers ------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//===----------------------------------------------------------------------===//
//
// This is a utility class for instrumentation passes (like AddressSanitizer
// or ThreadSanitizer) to avoid instrumenting some functions or global
// variables based on a user-supplied blacklist.
//
// The blacklist disables instrumentation of various functions and global
// variables.  Each line contains a prefix, followed by a wild card expression.
// Empty lines and lines starting with "#" are ignored.
// ---
// # Blacklisted items:
// fun:*_ZN4base6subtle*
// global:*global_with_bad_access_or_initialization*
// global-init:*global_with_initialization_issues*
// global-init-type:*Namespace::ClassName*
// src:file_with_tricky_code.cc
// ---
// Note that the wild card is in fact an llvm::Regex, but * is automatically
// replaced with .*
// This is similar to the "ignore" feature of ThreadSanitizer.
// http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores
//
//===----------------------------------------------------------------------===//
//

#include "llvm/ADT/StringMap.h"

namespace llvm {
class Function;
class GlobalVariable;
class Module;
class Regex;
class StringRef;

class BlackList {
 public:
  BlackList(const StringRef Path);
  // Returns whether either this function or it's source file are blacklisted.
  bool isIn(const Function &F);
  // Returns whether either this global or it's source file are blacklisted.
  bool isIn(const GlobalVariable &G);
  // Returns whether this module is blacklisted by filename.
  bool isIn(const Module &M);
  // Returns whether a global should be excluded from initialization checking.
  bool isInInit(const GlobalVariable &G);
 private:
  StringMap<Regex*> Entries;

  bool inSection(const StringRef Section, const StringRef Query);
};

}  // namespace llvm