llvm-project/clang/lib
Stephan Bergmann 8c85bca5a5 No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17
As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

This change removes exception specifications from the function types recorded
for -fsanitize=function, both in the functions themselves and at the call sites.
That means that calling a non-noexcept function through a noexcept pointer will
also not be flagged as UB.  In the review of this change, that was deemed
acceptable, at least for now.  (See the "TODO" in compiler-rt
test/ubsan/TestCases/TypeCheck/Function/function.cpp.)

To remove exception specifications from types, the existing internal
ASTContext::getFunctionTypeWithExceptionSpec was made public, and some places
otherwise unrelated to this change have been adapted to call it, too.

This is the cfe part of a patch covering both cfe and compiler-rt.

Differential Revision: https://reviews.llvm.org/D40720

llvm-svn: 321859
2018-01-05 07:57:12 +00:00
..
ARCMigrate Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:19 +00:00
AST No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17 2018-01-05 07:57:12 +00:00
ASTMatchers Remove creation of out-of-bounds value of enumeration type (resulting in UB). 2017-12-08 23:29:59 +00:00
Analysis [AST] Inline CompoundStmt contents into the parent allocation. 2017-12-24 16:24:20 +00:00
Basic Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones 2018-01-05 02:33:18 +00:00
CodeGen No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17 2018-01-05 07:57:12 +00:00
CrossTU [CrossTU] Fix handling of Cross Translation Unit directory path 2017-10-27 12:53:37 +00:00
Driver [Driver] Fix unused variables and test-writing-into-workdir after r321621 2018-01-02 09:35:10 +00:00
Edit [clang] Fix format specifiers fixits for nested macros 2017-06-20 20:46:58 +00:00
Format Revert "[ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC style" 2017-12-14 21:44:11 +00:00
Frontend Calculate size of buffer instead of using a magic value. 2018-01-03 20:29:49 +00:00
FrontendTool [CMake] Use #cmakedefine01 for CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) 2017-10-18 05:21:17 +00:00
Headers [DOXYGEN] Fix doxygen and content issues in smmintrin.h 2018-01-02 20:45:29 +00:00
Index [Index] Reduce size of SymbolInfo struct. 2017-12-23 19:31:24 +00:00
Lex Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones 2018-01-05 02:33:18 +00:00
Parse Again reverting an attempt to convert the DeclSpec enums into scoped enums. 2018-01-01 18:23:28 +00:00
Rewrite [analyzer] Add Javascript to analyzer HTML output to allow keyboard navigation. 2017-12-21 22:57:51 +00:00
Sema No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17 2018-01-05 07:57:12 +00:00
Serialization NFC. 2018-01-05 02:22:52 +00:00
StaticAnalyzer [analyzer] do not crash with assertion on processing locations of bodyfarmed functions 2018-01-02 23:05:47 +00:00
Tooling [Tooling] Acknowledge that many CompilationDatabases don't support enumeration. 2017-11-24 12:13:55 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00