Page MenuHomePhabricator

[Driver] Use VFS to check if sanitizer blacklists exist
ClosedPublic

Authored by ilya-biryukov on Nov 19 2019, 6:34 AM.

Details

Summary

This is a follow-up to 590f279c456bbde632eca8ef89a85c478f15a249, which
moved some of the callers to use VFS.

It turned out more code in Driver calls into real filesystem APIs and
also needs an update.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Nov 19 2019, 6:34 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 19 2019, 6:34 AM
ilya-biryukov added inline comments.Nov 19 2019, 6:42 AM
clang/unittests/Driver/SanitizerArgsTest.cpp
101

I'm pretty sure this is going to fail on Windows, looking for ideas on how to unify this with minimal code...
Let me know if there's some cool trick for this that I should know...

ilya-biryukov added inline comments.Nov 19 2019, 6:45 AM
clang/unittests/Driver/SanitizerArgsTest.cpp
72

NIT to self: remove this newline and the one before return

ilya-biryukov edited reviewers, added: gribozavr2; removed: gribozavr.Nov 19 2019, 10:34 AM
jkorous added inline comments.Nov 19 2019, 11:24 AM
clang/unittests/Driver/SanitizerArgsTest.cpp
101

Would llvm::sys::path::convert_to_slash() help?

142

Nit

kadircet added inline comments.Nov 21 2019, 1:16 AM
clang/unittests/Driver/SanitizerArgsTest.cpp
38

can't this be just clang ? as we are passing the resource-dir explicitly anyway

would be nice to not depend on any relative path deduction in the test.

45

nit s/emulateCompilation/emulateSingleCompilation/

54

nit: maybe put InputFile as the last entry in Args ?

101

maybe make this explicit with smthng like concat(ResourceDir, "share", "asan_blacklist.txt") instead of ASanBlackList?

101

Would llvm::sys::path::convert_to_slash() help?

+1 to this, maybe go over Command.getArguments and create a normalized version first, and then check over that one.

ilya-biryukov marked 7 inline comments as done.
  • Address comments
ilya-biryukov marked 3 inline comments as done.Nov 21 2019, 1:36 AM
kadircet accepted this revision.Nov 21 2019, 1:41 AM

thanks!

clang/unittests/Driver/SanitizerArgsTest.cpp
90

nit: semicolon

This revision is now accepted and ready to land.Nov 21 2019, 1:41 AM
ilya-biryukov marked an inline comment as done.
  • Remove redundant semicolon
This revision was automatically updated to reflect the committed changes.

FYI, this doesn't compile, see: http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/10890 (and probably all other build bots that are starting to break).

FAILED: tools/sancov/CMakeFiles/sancov.dir/sancov.cpp.o                                                                                                                                                             
/usr/lib/ccache/bin/clang++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/sancov -I/home/teemperor/work/ci/llvm/llvm/tools/sancov -I/usr/
include/libxml2 -Iinclude -I/home/teemperor/work/ci/llvm/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wc
ast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-col
or -ffunction-sections -fdata-sections -O3    -UNDEBUG  -fno-exceptions -fno-rtti -std=c++14 -MD -MT tools/sancov/CMakeFiles/sancov.dir/sancov.cpp.o -MF tools/sancov/CMakeFiles/sancov.dir/sancov.cpp.o.d -o tools/
sancov/CMakeFiles/sancov.dir/sancov.cpp.o -c /home/teemperor/work/ci/llvm/llvm/tools/sancov/sancov.cpp                                                                                                              
/home/teemperor/work/ci/llvm/llvm/tools/sancov/sancov.cpp:513:56: error: too few arguments to function call, expected 2, have 1                                                                                     
    return SpecialCaseList::createOrDie({{ClBlacklist}});                                                                                                                                                           
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~                ^                                                                                                                                                            
/home/teemperor/work/ci/llvm/llvm/include/llvm/Support/SpecialCaseList.h:80:3: note: 'createOrDie' declared here                                                                                                    
  static std::unique_ptr<SpecialCaseList>                                                                                                                                                                           
  ^                                                                                                                                                                                                                 
1 error generated.

@teemperor Sorry for the trouble. I did not run LLVM tests, so had to revert the change.

Was reverted in 9f3fdb0d7fab73083e354768eb5808597474e1b8 and relanded as aa981c1802d7353c777e399f2568e5a0e12dea21

Thanks for the quick fix!

Do we need to add a dep on Frontend to DriverTests here? That's a heavy dependency (it pulls in Sema etc). If it is needed, maybe the test is in the wrong binary?

Do we need to add a dep on Frontend to DriverTests here? That's a heavy dependency (it pulls in Sema etc). If it is needed, maybe the test is in the wrong binary?

We need it solely for TextDiagnosticPrinter. Very handy to see the errors in case of failures.
There are probably no reasons it cannot live outside frontend, should be a manageable refactoring. (I haven't checked though, might be wrong)

Logically, the tests seem to be in the right place.

I agree it's not perfect, but there are probably more useful things one can spend their time on.