[ubsan] Fix error summary message for ObjC BOOL invalid loads

llvm-svn: 302211
This commit is contained in:
Vedant Kumar 2017-05-05 01:35:42 +00:00
parent d45003ca19
commit 6a877cfec4
2 changed files with 16 additions and 1 deletions

View File

@ -410,7 +410,8 @@ static void handleLoadInvalidValue(InvalidValueData *Data, ValueHandle Val,
SourceLocation Loc = Data->Loc.acquire();
// This check could be more precise if we used different handlers for
// -fsanitize=bool and -fsanitize=enum.
bool IsBool = (0 == internal_strcmp(Data->Type.getTypeName(), "'bool'"));
bool IsBool = (0 == internal_strcmp(Data->Type.getTypeName(), "'bool'")) ||
(0 == internal_strncmp(Data->Type.getTypeName(), "'BOOL'", 6));
ErrorType ET =
IsBool ? ErrorType::InvalidBoolLoad : ErrorType::InvalidEnumLoad;

View File

@ -0,0 +1,14 @@
// RUN: %clang -fsanitize=bool %s -O3 -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: %env_ubsan_opts=print_summary=1:report_error_type=1 not %run %t 2>&1 | FileCheck %s --check-prefix=SUMMARY
typedef char BOOL;
unsigned char NotABool = 123;
int main(int argc, char **argv) {
BOOL *p = (BOOL*)&NotABool;
// CHECK: bool.m:[[@LINE+1]]:10: runtime error: load of value 123, which is not a valid value for type 'BOOL'
return *p;
// SUMMARY: SUMMARY: {{.*}}Sanitizer: invalid-bool-load {{.*}}bool.m:[[@LINE-1]]
}