@@ -85,13 +85,14 @@ enum VariableTypeDescriptorKind : uint16_t {
8585//                         Miscellaneous Helper Methods
8686// ===--------------------------------------------------------------------===//
8787
88- static  llvm::StringRef GetTrapMessageForHandler (SanitizerHandler ID) {
88+ static  llvm::StringRef GetUBSanTrapForHandler (SanitizerHandler ID) {
8989  switch  (ID) {
9090  case  SanitizerHandler::AddOverflow:
91-     return  " Signed integer addition overflowed. "  ;
91+     return  " Signed integer addition overflowed"  ;
9292
9393  case  SanitizerHandler::BuiltinUnreachable:
94-     return  " _builtin_unreachable() executed."  ;
94+     return  " _builtin_unreachable(), execution reached an unreachable program " 
95+            " point"  ;
9596
9697  case  SanitizerHandler::CFICheckFail:
9798    return  " Control flow integrity check failed"  ;
@@ -115,13 +116,14 @@ static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
115116    return  " Invalid use of builtin function"  ;
116117
117118  case  SanitizerHandler::InvalidObjCCast:
118-     return  " Invalid Objective-C cast. "  ;
119+     return  " Invalid Objective-C cast"  ;
119120
120121  case  SanitizerHandler::LoadInvalidValue:
121-     return  " Loaded an invalid or uninitialized value"  ;
122+     return  " Loaded an invalid or uninitialized value for the type "  ;
122123
123124  case  SanitizerHandler::MissingReturn:
124-     return  " Non-void function fell off end without return"  ;
125+     return  " Execution reached the end of a value-returning function without " 
126+            " returning a value"  ;
125127
126128  case  SanitizerHandler::MulOverflow:
127129    return  " Signed integer multiplication overflowed"  ;
@@ -130,20 +132,20 @@ static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
130132    return  " Signed integer negation overflowed"  ;
131133
132134  case  SanitizerHandler::NullabilityArg:
133-     return  " Passing null as a function parameter  which is annotated with " 
135+     return  " Passing null as an argument  which is annotated with " 
134136           " _Nonnull"  ;
135137
136138  case  SanitizerHandler::NullabilityReturn:
137139    return  " Returning null from a function with a return type annotated with " 
138140           " _Nonnull"  ;
139141
140142  case  SanitizerHandler::NonnullArg:
141-     return  " Passing null as a function parameter  which is declared to never be " 
143+     return  " Passing null pointer  as an argument  which is declared to never be " 
142144           " null"  ;
143145
144146  case  SanitizerHandler::NonnullReturn:
145147    return  " Returning null pointer from a function which is declared to never " 
146-            " be  null"  ;
148+            " return  null"  ;
147149
148150  case  SanitizerHandler::OutOfBounds:
149151    return  " Array index out of bounds"  ;
@@ -152,22 +154,22 @@ static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) {
152154    return  " Pointer arithmetic overflowed bounds"  ;
153155
154156  case  SanitizerHandler::ShiftOutOfBounds:
155-     return  " Shift amount exceeds bit-width of operand "  ;
157+     return  " Shift exponent is too large for the type "  ;
156158
157159  case  SanitizerHandler::SubOverflow:
158160    return  " Signed integer subtraction overflowed"  ;
159161
160162  case  SanitizerHandler::TypeMismatch:
161163    return  " Type mismatch in operation"  ;
162164
163-   case  SanitizerHandler::AlignmentAssumption:  //  Help on bottom 2 
165+   case  SanitizerHandler::AlignmentAssumption:
164166    return  " Alignment assumption violated"  ;
165167
166168  case  SanitizerHandler::VLABoundNotPositive:
167-     return  " Variable- length array bound is not  positive"  ;
169+     return  " Variable  length array bound evaluates to non- positive value "  ;
168170
169-   default :
170-     return  " "  ;
171+   case  SanitizerHandler::BoundsSafety :
172+     return  {} ;
171173  }
172174}
173175
@@ -4138,12 +4140,11 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
41384140  llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
41394141
41404142  llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation ();
4141-   llvm::StringRef Category = " UBSan Trap Reason"  ;
4142-   llvm::StringRef TrapMessage = GetTrapMessageForHandler (CheckHandlerID);
4143+   llvm::StringRef TrapMessage = GetUBSanTrapForHandler (CheckHandlerID);
41434144
4144-   if  (getDebugInfo () && !Category. empty () ) {
4145+   if  (getDebugInfo ()) {
41454146    TrapLocation = getDebugInfo ()->CreateTrapFailureMessageFor (
4146-         TrapLocation, Category , TrapMessage);
4147+         TrapLocation, " Undefined Behavior Sanitizer "  , TrapMessage);
41474148  }
41484149
41494150  NoMerge = NoMerge || !CGM.getCodeGenOpts ().OptimizationLevel  ||
@@ -4154,16 +4155,8 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
41544155    auto  Call = TrapBB->begin ();
41554156    assert (isa<llvm::CallInst>(Call) && " Expected call in trap BB"  );
41564157
4157-     //  Call->applyMergedLocation(Call->getDebugLoc(),
4158-     //                            Builder.getCurrentDebugLocation());
41594158    Call->applyMergedLocation (Call->getDebugLoc (), TrapLocation);
41604159
4161-     auto  Unreachable = ++TrapBB->begin ();
4162-     if  (isa<llvm::UnreachableInst>(Unreachable)) {
4163-       Unreachable->applyMergedLocation (Unreachable->getDebugLoc (),
4164-                                        TrapLocation);
4165-     }
4166- 
41674160    Builder.CreateCondBr (Checked, Cont, TrapBB,
41684161                         MDHelper.createLikelyBranchWeights ());
41694162  } else  {
0 commit comments