]> granicus.if.org Git - clang/commitdiff
Make CallExpr::isBuiltinConstantExpr slightly more efficient.
authorAnders Carlsson <andersca@mac.com>
Thu, 31 Jan 2008 02:13:57 +0000 (02:13 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 31 Jan 2008 02:13:57 +0000 (02:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46594 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp

index 88c1b236e8ece58bcc27e9b62283ee363654c62c..f02e817f0659dadc461ca9e2b5801b4a80177ef4 100644 (file)
@@ -130,9 +130,16 @@ bool CallExpr::isBuiltinConstantExpr() const {
   if (!DRE)
     return false;
 
-  // We have a DeclRefExpr.
-  if (strcmp(DRE->getDecl()->getName(), 
-             "__builtin___CFStringMakeConstantString") == 0)
+  const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());
+  if (!FDecl)
+    return false;
+    
+  unsigned builtinID = FDecl->getIdentifier()->getBuiltinID();
+  if (!builtinID)
+    return false;
+
+  // We have a builtin that is a constant expression
+  if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
     return true;
   return false;
 }