Files
clang-p2996/clang/lib/Basic/SanitizerBlacklist.cpp
Alexey Samsonov a511cdd247 Allow to specify multiple -fsanitize-blacklist= arguments.
Summary:
Allow user to provide multiple blacklists by passing several
-fsanitize-blacklist= options. These options now don't override
default blacklist from Clang resource directory, which is always
applied (which fixes PR22431).

-fno-sanitize-blacklist option now disables all blacklists that
were specified earlier in the command line (including the default
one).

This change depends on http://reviews.llvm.org/D7367.

Test Plan: regression test suite

Reviewers: timurrrr

Subscribers: cfe-commits, kcc, pcc

Differential Revision: http://reviews.llvm.org/D7368

llvm-svn: 228156
2015-02-04 17:40:08 +00:00

47 lines
1.7 KiB
C++

//===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// User-provided blacklist used to disable/alter instrumentation done in
// sanitizers.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/SanitizerBlacklist.h"
using namespace clang;
SanitizerBlacklist::SanitizerBlacklist(
const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
: SCL(llvm::SpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName,
StringRef Category) const {
return SCL->inSection("global", GlobalName, Category);
}
bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName,
StringRef Category) const {
return SCL->inSection("type", MangledTypeName, Category);
}
bool SanitizerBlacklist::isBlacklistedFunction(StringRef FunctionName) const {
return SCL->inSection("fun", FunctionName);
}
bool SanitizerBlacklist::isBlacklistedFile(StringRef FileName,
StringRef Category) const {
return SCL->inSection("src", FileName, Category);
}
bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc,
StringRef Category) const {
return !Loc.isInvalid() &&
isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category);
}