clang API Documentation

SanitizerBlacklist.cpp
Go to the documentation of this file.
00001 //===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // User-provided blacklist used to disable/alter instrumentation done in
00011 // sanitizers.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 #include "clang/Basic/SanitizerBlacklist.h"
00015 
00016 using namespace clang;
00017 
00018 SanitizerBlacklist::SanitizerBlacklist(StringRef BlacklistPath,
00019                                        SourceManager &SM)
00020     : SCL(llvm::SpecialCaseList::createOrDie(BlacklistPath)), SM(SM) {}
00021 
00022 bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName,
00023                                              StringRef Category) const {
00024   return SCL->inSection("global", GlobalName, Category);
00025 }
00026 
00027 bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName,
00028                                            StringRef Category) const {
00029   return SCL->inSection("type", MangledTypeName, Category);
00030 }
00031 
00032 bool SanitizerBlacklist::isBlacklistedFunction(StringRef FunctionName) const {
00033   return SCL->inSection("fun", FunctionName);
00034 }
00035 
00036 bool SanitizerBlacklist::isBlacklistedFile(StringRef FileName,
00037                                            StringRef Category) const {
00038   return SCL->inSection("src", FileName, Category);
00039 }
00040 
00041 bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc,
00042                                                StringRef Category) const {
00043   return !Loc.isInvalid() &&
00044          isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category);
00045 }
00046