summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/SanitizerArgs.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [SanitizerCoverage] Give clang-cc1 the power to precisly specify needed ↵Alexey Samsonov2015-05-071-3/+8
| | | | | | | | | | | | | | | | | | sanitizier coverage mode. Summary: The next step is to add user-friendly control over these options to driver via -fsanitize-coverage= option. Test Plan: regression test suite Reviewers: kcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9545 llvm-svn: 236756
* Allow UBSan+MSan and UBSan+TSan combinations (Clang part).Alexey Samsonov2015-04-281-4/+4
| | | | | | | | Embed UBSan runtime into TSan and MSan runtimes in the same as we do in ASan. Extend UBSan test suite to also run tests for these combinations. llvm-svn: 235953
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-131-2/+1
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-1/+2
| | | | llvm-svn: 234786
* Implement CFI type checks for non-virtual calls.Peter Collingbourne2015-04-021-1/+1
| | | | | | | | | | | | This uses the same class metadata currently used for virtual call and cast checks. The new flag is -fsanitize=cfi-nvcall. For consistency, the -fsanitize=cfi-vptr flag has been renamed -fsanitize=cfi-vcall. Differential Revision: http://reviews.llvm.org/D8756 llvm-svn: 233874
* [UBSan] Embed UBSan into ASan runtime (Clang part).Alexey Samsonov2015-04-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Change the way we use ASan and UBSan together. Instead of keeping two separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on a platform, all UBSan sources are just compiled into dummy empty object files. UBSan initialization code (e.g. flag parsing) is directly called from ASan initialization, so we are able to enforce correct initialization order. This mirrors the approach we already use for ASan+LSan. This change doesn't modify the way we use standalone UBSan. Test Plan: regression test suite Reviewers: kubabrecka, zaks.anna, kcc, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8645 llvm-svn: 233860
* [UBSan] Don't allow to use UBSan with anything except for ASan.Alexey Samsonov2015-03-201-69/+66
| | | | | | | | | | We are not able to make a reliable solution for using UBSan together with other sanitizers with runtime support (and sanitizer_common). Instead, we want to follow the path used for LSan: have a "standalone" UBSan tool, and plug-in UBSan that would be explicitly embedded into specific sanitizers (in short term, it will be only ASan). llvm-svn: 232829
* Allow -fsanitize-coverage with -fsanitize=dataflowKostya Serebryany2015-03-201-1/+1
| | | | | | | | | | | | | | | | Summary: Allow -fsanitize-coverage with -fsanitize=dataflow Test Plan: check-clang Reviewers: pcc Reviewed By: pcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8476 llvm-svn: 232787
* Implement bad cast checks using control flow integrity information.Peter Collingbourne2015-03-141-2/+2
| | | | | | | | | | | This scheme checks that pointer and lvalue casts are made to an object of the correct dynamic type; that is, the dynamic type of the object must be a derived class of the pointee type of the cast. The checks are currently only introduced where the class being casted to is a polymorphic class. Differential Revision: http://reviews.llvm.org/D8312 llvm-svn: 232241
* Add deprecation notice for -f(no-)sanitize-recover flags.Alexey Samsonov2015-03-111-2/+7
| | | | | | | These flags should be replaced with corresponding -f(no-)sanitize-recover=<list> flags. llvm-svn: 231983
* [Sanitizers] Use uint64_t for bitmask of enabled sanitizers.Alexey Samsonov2015-03-031-40/+40
| | | | | | | The total number of sanitizers and sanitizer groups will soon reach 32. llvm-svn: 231149
* [msan] Change track-origins default mode from 1 to 2.Evgeniy Stepanov2015-02-261-1/+1
| | | | | | | | | | | Change -fsanitize-memory-track-origins to be equivalent to -fsanitize-memory-track-origins=2. Track-origins=2 provides a lot more detailed reports at the cost of some additional slowdown (ranging from none to, sometimes, 3x; ~3% average on SPEC2006). llvm-svn: 230644
* [TSan][Clang][MIPS] Enabled thread option for MIPS64 platformMohit K. Bhakkad2015-02-231-1/+1
| | | | | | | | Reviewers: kcc, samsonov, petarj, eugenis Differential Revision: http://reviews.llvm.org/D6147 llvm-svn: 230209
* Implement Control Flow Integrity for virtual calls.Peter Collingbourne2015-02-201-1/+6
| | | | | | | | | | | | | | | This patch introduces the -fsanitize=cfi-vptr flag, which enables a control flow integrity scheme that checks that virtual calls take place using a vptr of the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst file. It also introduces the -fsanitize=cfi flag, which is currently a synonym for -fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented in Clang. Differential Revision: http://reviews.llvm.org/D7424 llvm-svn: 230055
* Improve our handling of rtti/sanitize=vptr/sanitize=undefinedFilipe Cabecinhas2015-02-191-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the huge blob of code that is dealing with rtti/exceptions/sanitizers and replaces it with: A ToolChain function which, for a given set of Args, figures out if rtti should be: - enabled - disabled implicitly - disabled explicitly A change in the way SanitizerArgs figures out what sanitizers to enable (or if it should error out, or warn); And a check for exceptions/rtti interaction inside addExceptionArgs. The RTTIMode algorithm is: - If -mkernel, -fapple-kext, or -fno-rtti are passed, rtti was disabled explicitly; - If -frtti was passed or we're not targetting the PS4, rtti is enabled; - If -fexceptions or -fcxx-exceptions was passed and we're targetting the PS4, rtti was enabled implicitly; - If we're targetting the PS4, rtti is disabled implicitly; - Otherwise, rtti is enabled; Since the only flag needed to pass to -cc1 is -fno-rtti if we want to disable it, there's no problem in saying rtti is enabled if we're compiling C code, so we don't look at the input file type. addExceptionArgs now looks at the RTTIMode and warns that rtti is being enabled implicitly if targetting the PS4 and exceptions are on. It also errors out if, targetting the PS4, -fno-rtti was passed, and exceptions were turned on. SanitizerArgs now errors out if rtti was disabled explicitly and the vptr sanitizer was enabled implicitly, but just turns off vptr if rtti is disabled but -fsanitize=undefined was passed. Also fixed tests, removed duplicate name from addExceptionArgs comment, and added one or two surrounding lines when running clang-format. This changes test/Driver/fsanitize.c to make it not expect a warning when passed -fsanitize=undefined -fno-rtti, but expect vptr to not be on. Removed all users and definition of SanitizerArgs::sanitizesVptr(). Reviewers: samsonov Subscribers: llvm-commits, samsonov, rsmith Differential Revision: http://reviews.llvm.org/D7525 llvm-svn: 229801
* Append -fno-assume-sane-operator-new in ASan builds.Sergey Matveev2015-02-171-2/+7
| | | | | | | This should help LSan detect leaks where operator new would otherwise be optimized out. llvm-svn: 229498
* Allow to specify multiple -fsanitize-blacklist= arguments.Alexey Samsonov2015-02-041-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [MSan][Clang][MIPS] Enabled memory and dataflow options for MIPS64 platformMohit K. Bhakkad2015-01-221-1/+3
| | | | | Reviewers: kcc, samsonov, petarj, eugenis llvm-svn: 226790
* Reimplement -fsanitize-recover family of flags.Alexey Samsonov2015-01-121-7/+45
| | | | | | | | | | | | | | | | | | | | | | | | Introduce the following -fsanitize-recover flags: - -fsanitize-recover=<list>: Enable recovery for selected checks or group of checks. It is forbidden to explicitly list unrecoverable sanitizers here (that is, "address", "unreachable", "return"). - -fno-sanitize-recover=<list>: Disable recovery for selected checks or group of checks. - -f(no-)?sanitize-recover is now a synonym for -f(no-)?sanitize-recover=undefined,integer and will soon be deprecated. These flags are parsed left to right, and mask of "recoverable" sanitizer is updated accordingly, much like what we do for -fsanitize= flags. -fsanitize= and -fsanitize-recover= flag families are independent. CodeGen change: If there is a single UBSan handler function, responsible for implementing multiple checks, which have different recoverable setting, then we emit two handler calls instead of one: the first one for the set of "unrecoverable" checks, another one - for set of "recoverable" checks. If all checks implemented by a handler have the same recoverability setting, then the generated code will be the same. llvm-svn: 225719
* Allow -fsanitize-coverage=N with ubsan, clang partKostya Serebryany2015-01-061-2/+3
| | | | | | | | | | | | | | | | | | | | Summary: Allow -fsanitize-coverage=N with ubsan, clang part. This simply allows the flag combination. The LLVM will work out of the box, the compile-rt part will follow as a separate patch. Test Plan: check-clang Reviewers: samsonov Reviewed By: samsonov Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6849 llvm-svn: 225229
* Allow to disable all sanitizers with "-fno-sanitize=all" option.Alexey Samsonov2014-12-191-5/+14
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds "all" sanitizer group. A shortcut "-fno-sanitize=all" can be used to disable all sanitizers for a given source file. "-fsanitize=all" option makes no sense, and will produce an error. This group can also be useful when we add "-fsanitize-recover=<list>" options (patch in http://reviews.llvm.org/D6302), as it would allow to conveniently enable/disable recovery for all specified sanitizers. Test Plan: regression test suite Reviewers: kcc, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6733 llvm-svn: 224596
* [Sanitizer] Get rid of parseArgument helper function. NFC.Alexey Samsonov2014-12-191-54/+43
| | | | llvm-svn: 224564
* [sanitizer] allow -fsanitize-coverage=N w/ -fsanitize=leak, clang partKostya Serebryany2014-12-171-2/+2
| | | | llvm-svn: 224462
* [msan] allow -fsanitize-coverage=N together with -fsanitize=memory, clang partKostya Serebryany2014-12-031-1/+1
| | | | llvm-svn: 223311
* clang: do not add -pie for tsanDmitry Vyukov2014-11-211-3/+3
| | | | | | | | | Revision 220571 removes the requirement to use -pie for tsan binaries. So remove -pie from driver. Also s/hasZeroBaseShadow/requiresPIE/ because that is what it is used for. Msan does not have zero-based shadow, but requires pie. And in general the relation between zero-based shadow and pie is unclear. http://reviews.llvm.org/D6318 llvm-svn: 222526
* [Sanitizer] Parse and produce all sanitizer-relevant arguments in SanitizerArgs.Alexey Samsonov2014-11-161-52/+61
| | | | | | | | | | | | | In particular, make SanitizerArgs responsible for parsing and passing down to frontend -fsanitize-recover and -fsanitize-undefined-trap-on-error flags. Simplify parsing -f(no-)sanitize= flags parsing: get rid of too complex filterUnsupportedKinds function. No functionality change. llvm-svn: 222105
* [Sanitizer] Refactor SanitizerArgs parsing in Driver.Alexey Samsonov2014-11-141-118/+213
| | | | | | | | | | | Remove flag parsing details from the public header. Use SanitizerSet to represent the set of enabled sanitizers. Cleanup the implementation: update the comments to reflect reality, remove dead code. No functionality change. llvm-svn: 221968
* Cleanup SanitizerArgs: get rid of unused variable, make one method ↵Alexey Samsonov2014-11-141-7/+2
| | | | | | non-static. NFC. llvm-svn: 221959
* Introduce -fsanitize-coverage=N flagKostya Serebryany2014-11-111-0/+15
| | | | | | | | | | | | | | | | | | | Summary: This change makes the asan-coverge (formerly -mllvm -asan-coverge) accessible via a clang flag. Companion patch to LLVM is http://reviews.llvm.org/D6152 Test Plan: regression tests, chromium Reviewers: samsonov Reviewed By: samsonov Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6153 llvm-svn: 221719
* Allow thread sanitizer in clang driver on FreeBSDViktor Kutuzov2014-10-271-4/+9
| | | | | | http://reviews.llvm.org/D5999 llvm-svn: 220680
* Revert rL220675 due to failures on check-clangViktor Kutuzov2014-10-271-6/+1
| | | | llvm-svn: 220677
* Allow thread sanitizer in clang driver on FreeBSDViktor Kutuzov2014-10-271-1/+6
| | | | | | Differential Revision: http://reviews.llvm.org/D5994 llvm-svn: 220675
* clang-cl: Diagnose the usage of ASAN with a debug runtime libraryEhsan Akhgari2014-10-141-0/+15
| | | | | | | | | | | | | | | | Summary: AddressSanitizer currently doesn't support this configuration, and binaries built with it will just get into an infinite loop during startup. Test Plan: Includes an automated test. Reviewers: samsonov Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5764 llvm-svn: 219744
* Add experimental clang/driver flag -fsanitize-address-field-padding=NKostya Serebryany2014-10-091-1/+13
| | | | | | | | | | | | | | | | | | | | | | | Summary: This change adds an experimental flag -fsanitize-address-field-padding=N (0, 1, 2) to clang and driver. With this flag ASAN will be able to detect some cases of intra-object-overflow bugs, see https://code.google.com/p/address-sanitizer/wiki/IntraObjectOverflow There is no actual functionality here yet, just the flag parsing. The functionality is being reviewed at http://reviews.llvm.org/D5687 Test Plan: Build and run SPEC, LLVM Bootstrap, Chrome with this flag. Reviewers: samsonov Reviewed By: samsonov Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5676 llvm-svn: 219417
* Add -link-cxx-sanitizer driver flag.Alexey Samsonov2014-08-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This flag can be used to force linking of CXX-specific parts of sanitizer runtimes into the final executable. It gives more precise control than --driver-mode=g++ and comes handy when user links several object files with sanitized C++ code into an executable, but wants to provide libstdc++ himself, instead of relying on Clang dirver's behavior. Test Plan: clang regression test suite Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4824 llvm-svn: 215252
* Decouple llvm::SpecialCaseList text representation and its LLVM IR semantics.Alexey Samsonov2014-07-091-1/+1
| | | | | | | | | | | | | | | | Turn llvm::SpecialCaseList into a simple class that parses text files in a specified format and knows nothing about LLVM IR. Move this class into LLVMSupport library. Implement two users of this class: * DFSanABIList in DFSan instrumentation pass. * SanitizerBlacklist in Clang CodeGen library. The latter will be modified to use actual source-level information from frontend (source file names) instead of unstable LLVM IR things (LLVM Module identifier). Remove dependency edge from ClangCodeGen/ClangDriver to LLVMTransformUtils. No functionality change. llvm-svn: 212643
* Remove top-level Clang -fsanitize= flags for optional ASan features.Alexey Samsonov2014-06-131-13/+0
| | | | | | | | | | | | | Init-order and use-after-return modes can currently be enabled by runtime flags. use-after-scope mode is not really working at the moment. The only problem I see is that users won't be able to disable extra instrumentation for init-order and use-after-scope by a top-level Clang flag. But this instrumentation was implicitly enabled for quite a while and we didn't hear from users hurt by it. llvm-svn: 210924
* Fix driver warning about -shared-libasan on Android.Evgeniy Stepanov2014-06-051-2/+2
| | | | | | | Asan runtime library is always shared on Android, and -shared-libasan is no-op. Suppress the unused argument warning. llvm-svn: 210252
* [C++11] Use 'nullptr'. Driver edition.Craig Topper2014-05-171-1/+1
| | | | llvm-svn: 209069
* Add support for dynamic ASan runtime (on Linux) to Clang driver.Alexey Samsonov2014-04-011-1/+6
| | | | | | Based on http://llvm-reviews.chandlerc.com/D3043 by Yuri Gribov! llvm-svn: 205310
* Kill deprecated -fbounds-checking flagAlexey Samsonov2014-03-211-11/+1
| | | | llvm-svn: 204436
* [msan] -fsanitize-memory-track-origins=[level] flag and docs.Evgeniy Stepanov2014-03-201-8/+25
| | | | | | | | | This change turns -fsanitize-memory-track-origins into -fsanitize-memory-track-origins=[level] flag (keeping the old one for compatibility). Possible levels are 0 (off), 1 (default) and 2 (incredibly detailed). See docs (part of this patch) for more info. llvm-svn: 204346
* Kill -faddress-sanitizer, -fthread-sanitizer and -fcatch-undefined-behavior ↵Alexey Samsonov2014-03-201-37/+5
| | | | | | | | | flags. These flags are deprecated since at least Clang 3.3. Users should instead use -fsanitize= with appropriate values. llvm-svn: 204330
* [C++11] Replace OwningPtr include with <memory>.Ahmed Charles2014-03-091-1/+1
| | | | llvm-svn: 203389
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-1/+1
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [asan] Remove -fsanitize-address-zero-base-shadow command lineEvgeniy Stepanov2014-01-161-19/+2
| | | | | | | | | | | | | | | | flag from clang, and disable zero-base shadow support on all platforms where it is not the default behavior. - It is completely unused, as far as we know. - It is ABI-incompatible with non-zero-base shadow, which means all objects in a process must be built with the same setting. Failing to do so results in a segmentation fault at runtime. - It introduces a backward dependency of compiler-rt on user code, which is uncommon and complicates testing. This is the Clang part of a larger change. llvm-svn: 199372
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+0
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* SanitizerArgs: add ability to filter/diagnose unsupported sanitizers.Peter Collingbourne2013-11-011-43/+108
| | | | | | | | | | | | The thread, memory, dataflow and function sanitizers are now diagnosed if enabled explicitly on an unsupported platform. Unsupported sanitizers which are enabled implicitly (as part of a larger group) are silently disabled. As a side effect, this makes SanitizerArgs parsing toolchain-dependent (and thus essentially reverts r188058), and moves SanitizerArgs ownership to ToolChain. Differential Revision: http://llvm-reviews.chandlerc.com/D1990 llvm-svn: 193875
* Split -fsanitize=bounds to -fsanitize=array-bounds (for the frontend-insertedRichard Smith2013-10-221-2/+2
| | | | | | | | | | | | | | check using the ubsan runtime) and -fsanitize=local-bounds (for the middle-end check which inserts traps). Remove -fsanitize=local-bounds from -fsanitize=undefined. It does not produce useful diagnostics and has false positives (PR17635), and is not a good compromise position between UBSan's checks and ASan's checks. Map -fbounds-checking to -fsanitize=local-bounds to restore Clang's historical behavior for that flag. llvm-svn: 193205
OpenPOWER on IntegriCloud