[cfe-commits] r50676 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/builtins.c
Chris Lattner
sabre at nondot.org
Mon May 5 15:18:14 PDT 2008
Author: lattner
Date: Mon May 5 17:18:14 2008
New Revision: 50676
URL: http://llvm.org/viewvc/llvm-project?rev=50676&view=rev
Log:
Fix rdar://5905347 a crash on invalid builtin, due to the
params not getting installed for builtins when synthesized.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/builtins.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=50676&r1=50675&r2=50676&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 5 17:18:14 2008
@@ -143,8 +143,7 @@
return 0;
}
-void Sema::InitBuiltinVaListType()
-{
+void Sema::InitBuiltinVaListType() {
if (!Context.getBuiltinVaListType().isNull())
return;
@@ -161,8 +160,8 @@
Builtin::ID BID = (Builtin::ID)bid;
if (BID == Builtin::BI__builtin_va_start ||
- BID == Builtin::BI__builtin_va_copy ||
- BID == Builtin::BI__builtin_va_end)
+ BID == Builtin::BI__builtin_va_copy ||
+ BID == Builtin::BI__builtin_va_end)
InitBuiltinVaListType();
QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);
@@ -171,6 +170,19 @@
SourceLocation(), II, R,
FunctionDecl::Extern, false, 0);
+ // Create Decl objects for each parameter, adding them to the
+ // FunctionDecl.
+ if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(R)) {
+ llvm::SmallVector<ParmVarDecl*, 16> Params;
+ for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
+ Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
+ FT->getArgType(i), VarDecl::None, 0,
+ 0));
+ New->setParams(&Params[0], Params.size());
+ }
+
+
+
// TUScope is the translation-unit scope to insert this function into.
TUScope->AddDecl(New);
Modified: cfe/trunk/test/Sema/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.c?rev=50676&r1=50675&r2=50676&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtins.c (original)
+++ cfe/trunk/test/Sema/builtins.c Mon May 5 17:18:14 2008
@@ -30,3 +30,12 @@
CFSTR("foo", "bar"); // expected-error {{ error: too many arguments to function }}
}
+
+typedef __attribute__(( ext_vector_type(16) )) unsigned char uchar16; // expected-warning {{extension}}
+
+// rdar://5905347
+unsigned char foo( short v ) {
+ uchar16 c;
+ return __builtin_ia32_vec_ext_v4si( c ); // expected-error {{too few arguments to function}}
+}
+
More information about the cfe-commits
mailing list