diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-11 00:56:15 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-11 00:56:15 +0000 |
commit | 64a26308256adcf9212fd346733a60735f7acc01 (patch) | |
tree | 043986e4820875be83de38922ba301eb68d3a569 /clang/lib/AST/Decl.cpp | |
parent | d23cdbbeb2d5f9cf23baf62597c8c2a24ab2b8ef (diff) | |
download | bcm5719-llvm-64a26308256adcf9212fd346733a60735f7acc01.tar.gz bcm5719-llvm-64a26308256adcf9212fd346733a60735f7acc01.zip |
Pass the function type instead of the return type to FunctionDecl::Create
Fix places where the return type of a FunctionDecl was being used in
place of the function type
FunctionDecl::Create() takes as its T parameter the type of function
that should be created, not the return type. Passing in the return type
looks to have been copypasta'd around a bit, but the number of correct
usages outweighs the incorrect ones so I've opted for keeping what T is
the same and fixing up the call sites instead.
This fixes a crash in Clang when attempting to compile the following
snippet of code with -fblocks -fsanitize=function -x objective-c++ (my
original repro case):
void g(void(^)());
void f()
{
__block int a = 0;
g(^(){ a++; });
}
as well as the following which only requires -fsanitize=function -x c++:
void f(char * buf)
{
__builtin_os_log_format(buf, "");
}
Patch by: Ben (bobsayshilol)
Differential revision: https://reviews.llvm.org/D53263
llvm-svn: 346601
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 5477dc44041..5fa445f8d1c 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2652,6 +2652,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, StartLoc), DeclContext(DK), redeclarable_base(C), ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) { + assert(T.isNull() || T->isFunctionType()); setStorageClass(S); setInlineSpecified(isInlineSpecified); setExplicitSpecified(false); |