Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -72,6 +72,7 @@ #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" @@ -81,6 +82,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -826,13 +828,27 @@ llvm_unreachable("getAddressSpaceMapMangling() doesn't cover anything."); } +static std::vector +getRealPaths(llvm::vfs::FileSystem &VFS, llvm::ArrayRef Paths) { + std::vector Result; + llvm::SmallString<128> Buffer; + for (const auto &File : Paths) { + VFS.getRealPath(File, Buffer); + Result.push_back(Buffer.str()); + } + return Result; +} + ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins) : FunctionProtoTypes(this_()), TemplateSpecializationTypes(this_()), DependentTemplateSpecializationTypes(this_()), SubstTemplateTemplateParmPacks(this_()), SourceMgr(SM), LangOpts(LOpts), - SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, SM)), + SanitizerBL(new SanitizerBlacklist( + getRealPaths(SM.getFileManager().getVirtualFileSystem(), + LangOpts.SanitizerBlacklistFiles), + SM)), XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles, LangOpts.XRayNeverInstrumentFiles, LangOpts.XRayAttrListFiles, SM)), Index: clang/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml =================================================================== --- /dev/null +++ clang/test/CodeGen/Inputs/sanitizer-blacklist-vfsoverlay.yaml @@ -0,0 +1,12 @@ +{ + 'version': 0, + 'roots': [ + { 'name': 'DIR', 'type': 'directory', + 'contents': [ + { 'name': 'only-virtual-file.blacklist', 'type': 'file', + 'external-contents': 'REAL_FILE' + } + ] + } + ] +} Index: clang/test/CodeGen/ubsan-blacklist.c =================================================================== --- clang/test/CodeGen/ubsan-blacklist.c +++ clang/test/CodeGen/ubsan-blacklist.c @@ -5,6 +5,10 @@ // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE +// RUN: rm -f %t-vfsoverlay.yaml +// RUN: sed -e "s|DIR|%T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | sed -e "s|REAL_FILE|%t-func.blacklist|g" > %t-vfsoverlay.yaml +// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-blacklist=/Users/jankorous/src/llvm-monorepo-master/omegabuild/tools/clang/test/CodeGen/Output/only-virtual-file.blacklist -ivfsoverlay %t-vfsoverlay.yaml -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC + unsigned i; // DEFAULT: @hash