Add support for code generation of builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41188 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index b0d34a3..317a554 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -14,6 +14,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
+#include "clang/Lex/IdentifierTable.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
@@ -660,6 +661,15 @@
}
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
+ if (const ImplicitCastExpr *IcExpr =
+ dyn_cast<const ImplicitCastExpr>(E->getCallee()))
+ if (const DeclRefExpr *DRExpr =
+ dyn_cast<const DeclRefExpr>(IcExpr->getSubExpr()))
+ if (const FunctionDecl *FDecl =
+ dyn_cast<const FunctionDecl>(DRExpr->getDecl()))
+ if (unsigned builtinID = FDecl->getIdentifier()->getBuiltinID())
+ return EmitBuiltinExpr(builtinID, E);
+
llvm::Value *Callee = EmitExpr(E->getCallee()).getVal();
// The callee type will always be a pointer to function type, get the function