[clang] ea8e5b8 - [NFC] Remove duplicate isNoBuiltinFunc method

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 10 00:19:11 PST 2021


Author: serge-sans-paille
Date: 2021-03-10T09:18:55+01:00
New Revision: ea8e5b87acba4b7dad749d697a3969901652b97a

URL: https://github.com/llvm/llvm-project/commit/ea8e5b87acba4b7dad749d697a3969901652b97a
DIFF: https://github.com/llvm/llvm-project/commit/ea8e5b87acba4b7dad749d697a3969901652b97a.diff

LOG: [NFC] Remove duplicate isNoBuiltinFunc method

It's available both in CodeGenOptions and in LangOptions, and LangOptions
implementation is slightly better as it uses a StringRef instead of a char
pointer, so use it.

Differential Revision: https://reviews.llvm.org/D98175

Added: 
    

Modified: 
    clang/include/clang/Basic/CodeGenOptions.h
    clang/lib/Basic/CodeGenOptions.cpp
    clang/lib/CodeGen/CGCall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h
index 40068b4f6649..b38df2da97de 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -415,10 +415,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   CodeGenOptions();
 
-  /// Is this a libc/libm function that is no longer recognized as a
-  /// builtin because a -fno-builtin-* option has been specified?
-  bool isNoBuiltinFunc(const char *Name) const;
-
   const std::vector<std::string> &getNoBuiltinFuncs() const {
     return NoBuiltinFuncs;
   }

diff  --git a/clang/lib/Basic/CodeGenOptions.cpp b/clang/lib/Basic/CodeGenOptions.cpp
index 4fc7a535c9eb..0c609cfa61de 100644
--- a/clang/lib/Basic/CodeGenOptions.cpp
+++ b/clang/lib/Basic/CodeGenOptions.cpp
@@ -20,12 +20,4 @@ CodeGenOptions::CodeGenOptions() {
   memcpy(CoverageVersion, "408*", 4);
 }
 
-bool CodeGenOptions::isNoBuiltinFunc(const char *Name) const {
-  StringRef FuncName(Name);
-  for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
-    if (FuncName.equals(NoBuiltinFuncs[i]))
-      return true;
-  return false;
-}
-
 }  // end namespace clang

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index da993bed7ba0..34ad782d810c 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1765,8 +1765,7 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
 
   if (AttrOnCallSite) {
     // Attributes that should go on the call site only.
-    if (!CodeGenOpts.SimplifyLibCalls ||
-        CodeGenOpts.isNoBuiltinFunc(Name.data()))
+    if (!CodeGenOpts.SimplifyLibCalls || LangOpts.isNoBuiltinFunc(Name))
       FuncAttrs.addAttribute(llvm::Attribute::NoBuiltin);
     if (!CodeGenOpts.TrapFuncName.empty())
       FuncAttrs.addAttribute("trap-func-name", CodeGenOpts.TrapFuncName);


        


More information about the cfe-commits mailing list