summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-05 22:18:14 +0000
committerChris Lattner <sabre@nondot.org>2008-05-05 22:18:14 +0000
commit4dd271022202af507746f2e0e503f17bfb4e1c77 (patch)
treecfab195d8e27670f836a44a9e8db1bdbcefc39d3 /clang/lib/Sema/SemaDecl.cpp
parentdbfcce37fe46c153399a68f198ffb31872f9b8ce (diff)
downloadbcm5719-llvm-4dd271022202af507746f2e0e503f17bfb4e1c77.tar.gz
bcm5719-llvm-4dd271022202af507746f2e0e503f17bfb4e1c77.zip
Fix rdar://5905347 a crash on invalid builtin, due to the
params not getting installed for builtins when synthesized. llvm-svn: 50676
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f583ad1606a..2624f5019db 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -143,8 +143,7 @@ Decl *Sema::LookupDecl(const IdentifierInfo *II, unsigned NSI,
return 0;
}
-void Sema::InitBuiltinVaListType()
-{
+void Sema::InitBuiltinVaListType() {
if (!Context.getBuiltinVaListType().isNull())
return;
@@ -161,8 +160,8 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
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 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
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);
OpenPOWER on IntegriCloud