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

2017-02-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision. aaron.ballman added a comment. Committed in r294861. https://reviews.llvm.org/D28166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2017-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 83118. aaron.ballman added a comment. Added support for `AdjustedType` and `AdjustedTypeLoc`. 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/Sem

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

2017-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: lib/Sema/SemaDecl.cpp:11958-11962 +// The type location may be attributed; strip the attributes to get to +// the function type location. +while (auto ATL = TL.getAs()) { + TL = ATL.getModifiedLoc()

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

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments. Comment at: lib/Sema/SemaDecl.cpp:11958-11962 +// The type location may be attributed; strip the attributes to get to +// the function type location. +while (auto ATL = TL.getAs()) { + TL = ATL.getModifiedLoc(); +

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

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 82985. aaron.ballman marked 3 inline comments as done. aaron.ballman added a comment. Stripped out the codegen changes since @rnk 's commit fixed the issue. https://reviews.llvm.org/D28166 Files: include/clang/AST/Type.h include/clang/AST/TypeLoc.

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

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done. aaron.ballman added inline comments. Comment at: lib/CodeGen/CodeGenFunction.h:3570 for (auto *A : llvm::make_range(Arg, ArgRange.end())) - ArgTypes.push_back(getVarArgType(A)); + ArgTypes.push_back(getVarArgType(A, C

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

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments. Comment at: lib/CodeGen/CodeGenFunction.h:3570 for (auto *A : llvm::make_range(Arg, ArgRange.end())) - ArgTypes.push_back(getVarArgType(A)); + ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr)); rnk wrote:

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

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments. Comment at: lib/CodeGen/CodeGenFunction.h:3570 for (auto *A : llvm::make_range(Arg, ArgRange.end())) - ArgTypes.push_back(getVarArgType(A)); + ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr)); rnk wrote:

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

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments. Comment at: lib/CodeGen/CodeGenFunction.h:3570 for (auto *A : llvm::make_range(Arg, ArgRange.end())) - ArgTypes.push_back(getVarArgType(A)); + ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr)); I'm testin

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

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 82930. aaron.ballman added a comment. I've updated this patch to correct the codegen changes. If you'd prefer, I can review/commit in two separate phases, one for the codegen bug and one for the attribute issue, as I think these changes might be reason

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

2017-01-03 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment. In https://reviews.llvm.org/D28166#634196, @aaron.ballman wrote: > So I think the correct behavior is to only enable the vararg behavior when > the function is variadic with an ellipsis rather than variadic due to a lack > of prototype. That sounds right. Note that fun

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

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: majnemer. aaron.ballman added a comment. > I *think* the problem is that we gin up the function type for a > non-prototyped function based on the function call expression argument types, > and the literal `0` is getting the type `signed long long`. I think this i

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

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D28166#633643, @rsmith wrote: > In https://reviews.llvm.org/D28166#633621, @aaron.ballman wrote: > > > Do you think this patch should be gated on (or perhaps combined with) a fix > > for the lowering bug, or do you think this patch is re

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

2017-01-02 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment. In https://reviews.llvm.org/D28166#633621, @aaron.ballman wrote: > Do you think this patch should be gated on (or perhaps combined with) a fix > for the lowering bug, or do you think this patch is reasonable on its own? > Given that it turns working code into UB, I think

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

2017-01-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D28166#633595, @rsmith wrote: > The test failure in test/CodeGen/microsoft-call-conv-x64.c definitely > indicates a problem. The code has defined behavior, but the IR you say we now > produce has undefined behavior due to a type mismatc

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

2017-01-02 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment. The test failure in test/CodeGen/microsoft-call-conv-x64.c definitely indicates a problem. The code has defined behavior, but the IR you say we now produce has undefined behavior due to a type mismatch between the call and the callee. It looks to me like unprototyped `__

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

2017-01-02 Thread Aaron Ballman via Phabricator via cfe-commits
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 bein

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

2016-12-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: lib/Sema/SemaDecl.cpp:7464-7470 +const Type *NonAttributedFTy = R.getTypePtr(); +while (const auto *AttrTy = NonAttributedFTy->getAs()) { + NonAttributedFTy = AttrTy->getModifiedType().getTypePtr(); +} bool Ha

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

2016-12-29 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments. Comment at: lib/Sema/SemaDecl.cpp:7464-7470 +const Type *NonAttributedFTy = R.getTypePtr(); +while (const auto *AttrTy = NonAttributedFTy->getAs()) { + NonAttributedFTy = AttrTy->getModifiedType().getTypePtr(); +} bool HasProtot

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

2016-12-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision. aaron.ballman added a reviewer: rsmith. aaron.ballman added a subscriber: cfe-commits. When determining whether a function was written with a prototype, we would look at the type to see if it was something other than a FunctionType while the canonical type wa