[compiler-rt] r302211 - [ubsan] Fix error summary message for ObjC BOOL invalid loads

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 18:35:42 PDT 2017


Author: vedantk
Date: Thu May  4 20:35:42 2017
New Revision: 302211

URL: http://llvm.org/viewvc/llvm-project?rev=302211&view=rev
Log:
[ubsan] Fix error summary message for ObjC BOOL invalid loads

Added:
    compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.m
Modified:
    compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc

Modified: compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc?rev=302211&r1=302210&r2=302211&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_handlers.cc Thu May  4 20:35:42 2017
@@ -410,7 +410,8 @@ static void handleLoadInvalidValue(Inval
   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;
 

Added: compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.m
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.m?rev=302211&view=auto
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.m (added)
+++ compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.m Thu May  4 20:35:42 2017
@@ -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]]
+}




More information about the llvm-commits mailing list