From: Chris Lattner Date: Sun, 28 Sep 2008 05:54:29 +0000 (+0000) Subject: Replace a comparison with a static list of builtins that was wrong (it X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd7eb1c3b2af5cd0a7540c79da85e2ce15a893f4;p=clang Replace a comparison with a static list of builtins that was wrong (it wasn't covering checking builtins like __builtin___vsnprintf_chk) with a check that won't get out of date. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56767 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Builtins.h b/include/clang/AST/Builtins.h index d645de593f..0deaca6a68 100644 --- a/include/clang/AST/Builtins.h +++ b/include/clang/AST/Builtins.h @@ -78,6 +78,12 @@ public: return strchr(GetRecord(ID).Attributes, 'F') != 0; } + /// hasVAListUse - Return true of the specified builtin uses __builtin_va_list + /// as an operand or return type. + bool hasVAListUse(unsigned ID) const { + return strchr(GetRecord(ID).Type, 'a') != 0; + } + /// GetBuiltinType - Return the type for the specified builtin. QualType GetBuiltinType(unsigned ID, ASTContext &Context) const; private: diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index db1a7aef8b..9d3947bfcd 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -194,10 +194,7 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, Scope *S) { 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_stdarg_start) + if (Context.BuiltinInfo.hasVAListUse(BID)) InitBuiltinVaListType(); QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);