]> granicus.if.org Git - clang/commit
Pass the function type instead of the return type to FunctionDecl::Create
authorJonas Devlieghere <jonas@devlieghere.com>
Sun, 11 Nov 2018 00:56:15 +0000 (00:56 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Sun, 11 Nov 2018 00:56:15 +0000 (00:56 +0000)
commit7dec0f05fefde9d87b465d57d739230563b26584
tree914dbdd5178c3731e8779fd4b491aeddb79b54ec
parent5a7aa718fe09311c46e2ed86ade4ff564dfe990e
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346601 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/Decl.cpp
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CGNonTrivialStruct.cpp
lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGStmtOpenMP.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/Frontend/Rewrite/RewriteModernObjC.cpp
test/CodeGenObjCXX/crash-function-type.mm [new file with mode: 0644]