diff options
author | Chris Lattner <sabre@nondot.org> | 2007-06-13 20:44:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-06-13 20:44:40 +0000 |
commit | 53621a535d6bf9436d63a373e64264e1b70c10e3 (patch) | |
tree | add6ddc7a201f884e3105baa1efaa13c4e65331b /clang/AST/Decl.cpp | |
parent | 23cff88741f9d377fed74329cd524de5d4f0d8e2 (diff) | |
download | bcm5719-llvm-53621a535d6bf9436d63a373e64264e1b70c10e3.tar.gz bcm5719-llvm-53621a535d6bf9436d63a373e64264e1b70c10e3.zip |
Implement support for formal arguments. We can now compile this:
int test(int X, short Y, float Z) {
return (int)(X*Y+Z);
}
to:
define i32 @test(i32 %X, i16 %Y, float %Z) {
entry:
%promote = sext i16 %Y to i32 ; <i32> [#uses=1]
%mul = mul i32 %promote, %X ; <i32> [#uses=1]
%promote3 = sitofp i32 %mul to float ; <float> [#uses=1]
%add = add float %promote3, %Z ; <float> [#uses=1]
%conv = fptosi float %add to i32 ; <i32> [#uses=1]
ret i32 %conv
}
with:
$ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis
llvm-svn: 39652
Diffstat (limited to 'clang/AST/Decl.cpp')
-rw-r--r-- | clang/AST/Decl.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/AST/Decl.cpp b/clang/AST/Decl.cpp index ca37f7cfc9f..f7301181d72 100644 --- a/clang/AST/Decl.cpp +++ b/clang/AST/Decl.cpp @@ -124,14 +124,14 @@ unsigned FunctionDecl::getNumParams() const { return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs(); } -void FunctionDecl::setParams(VarDecl **NewParamInfo, unsigned NumParams) { +void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) { assert(ParamInfo == 0 && "Already has param info!"); assert(NumParams == getNumParams() && "Parameter count mismatch!"); // Zero params -> null pointer. if (NumParams) { - ParamInfo = new VarDecl*[NumParams]; - memcpy(ParamInfo, NewParamInfo, sizeof(VarDecl*)*NumParams); + ParamInfo = new ParmVarDecl*[NumParams]; + memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams); } } |