[PATCH] D28166: Properly merge K&R functions that have attributes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 13:50:10 PST 2017


aaron.ballman updated this revision to Diff 82816.
aaron.ballman added a comment.

I've updated the patch to not hard code the type adjustments, but instead added `Type::getAsAdjusted()` and `TypeLoc::getAsAdjusted()`.

This patch has one broken test case, but I do not think the test case was being triggered as its author expected. The failing test is clang\test\CodeGen\microsoft-call-conv-x64.c, and the failure is that the call to `f7()` does not match the CHECK line. Instead of `call void @f7(i32 0)`, you now get `call void bitcast (void (i32)* @f7 to void (i64)*)(i64 0)`.

Sema::BuildDeclarationNameExpr() has some code to check for K&R-style functions and ensuring that we lose prototype information in accordance with C DR 316. However, under the code prior to this patch, the predicate was false for this test case because `FD->hasPrototype()` would return true despite the function being a K&R function with no prototype. Since we corrected that behavior `FD->hasPrototype()` now returns false, prompting the adjustment, which alters the IR we generate. However, I'm not certain whether the altered IR is desired or not, so advice on this is welcome.


https://reviews.llvm.org/D28166

Files:
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  lib/Sema/SemaDecl.cpp
  test/Sema/knr-def-call.c
  test/Sema/warn-strict-prototypes.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28166.82816.patch
Type: text/x-patch
Size: 5944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170102/500028b3/attachment.bin>


More information about the cfe-commits mailing list