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
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 7063b76..7a04ffc 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -173,7 +173,7 @@
 
 /// 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 @@
   if (!FDecl->getIdentifier())
     return 0;
 
-  return FDecl->getBuiltinID();
+  return FDecl->getBuiltinID(Context);
 }
 
 
@@ -922,7 +922,7 @@
     
     // 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 @@
     // 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;