aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-14 18:57:46 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-14 18:57:46 +0000
commit3c385e5f8d9008fff18597ca302be19fa86e51f6 (patch)
tree8daddebd1007dcd0f23f8a442032c584da996663 /lib/AST/Expr.cpp
parentff975cfab9ada27df86038286d1678084aeb3428 (diff)
Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r--lib/AST/Expr.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 7063b768c5..7a04ffcedc 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -173,7 +173,7 @@ void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) {
/// isBuiltinCall - If this is a call to a builtin, return the builtin ID. If
/// not, return 0.
-unsigned CallExpr::isBuiltinCall() const {
+unsigned CallExpr::isBuiltinCall(ASTContext &Context) const {
// All simple function calls (e.g. func()) are implicitly cast to pointer to
// function. As a result, we try and obtain the DeclRefExpr from the
// ImplicitCastExpr.
@@ -192,7 +192,7 @@ unsigned CallExpr::isBuiltinCall() const {
if (!FDecl->getIdentifier())
return 0;
- return FDecl->getBuiltinID();
+ return FDecl->getBuiltinID(Context);
}
@@ -922,7 +922,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
// If this is a call to a builtin function, constant fold it otherwise
// reject it.
- if (CE->isBuiltinCall()) {
+ if (CE->isBuiltinCall(Ctx)) {
EvalResult EvalResult;
if (CE->Evaluate(EvalResult, Ctx)) {
assert(!EvalResult.HasSideEffects &&
@@ -1205,7 +1205,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
// expression, and it is fully evaluated. This is an important GNU
// extension. See GCC PR38377 for discussion.
if (const CallExpr *CallCE = dyn_cast<CallExpr>(Cond->IgnoreParenCasts()))
- if (CallCE->isBuiltinCall() == Builtin::BI__builtin_constant_p) {
+ if (CallCE->isBuiltinCall(Ctx) == Builtin::BI__builtin_constant_p) {
EvalResult EVResult;
if (!Evaluate(EVResult, Ctx) || EVResult.HasSideEffects)
return false;