[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 21 10:36:51 PST 2017

rsmith added inline comments.

Comment at: clang/lib/CodeGen/CodeGenTypes.h:378
+  /// specification removed.
+  QualType removeNothrowQualification(const FunctionProtoType *Proto) const;
Please use the frontend language terminology here: "nothrow" is appropriate when talking about an LLVM function, but for the frontend type we should call this "removeExceptionSpecification" or similar. It would make sense for this to live on `ASTContext` instead of `CodeGenTypes`, since it's an AST type transformation utility not something related to IR generation. (There's a call to `getFunctionType` in `Sema::IsFunctionConversion` that you could also convert to use this `ASTContext` utility function.)

Perhaps exposing the currently-internal `getFunctionTypeWithExceptionSpec` from ASTContext.cpp would be a good way forward. (That function also handles wrapping, unwrapping, and adjusting type sugar nodes, but has the same effect as this one on the canonical type.)

Comment at: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp:5
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void ()* @_Z1fv to i64)) to i32) }>
A name more meaningful than "LABEL" would be more useful to future readers of this code.


More information about the cfe-commits mailing list