]> granicus.if.org Git - clang/commitdiff
Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
authorMehdi Amini <mehdi.amini@apple.com>
Mon, 10 Oct 2016 21:34:29 +0000 (21:34 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Mon, 10 Oct 2016 21:34:29 +0000 (21:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283802 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Builtins.h
lib/CodeGen/CGBuiltin.cpp
lib/Sema/SemaChecking.cpp

index 87c1f93eedefe7649faf6094b81561e778a8da47..e765ddd5fdfdd00e25dd93def8594eadb0cadfbe 100644 (file)
@@ -51,7 +51,8 @@ enum ID {
 };
 
 struct Info {
-  const char *Name, *Type, *Attributes, *HeaderName;
+  llvm::StringRef Name;
+  const char *Type, *Attributes, *HeaderName;
   LanguageID Langs;
   const char *Features;
 };
@@ -80,7 +81,7 @@ public:
 
   /// \brief Return the identifier name for the specified builtin,
   /// e.g. "__builtin_abs".
-  const char *getName(unsigned ID) const {
+  llvm::StringRef getName(unsigned ID) const {
     return getRecord(ID).Name;
   }
 
index f9b38fa58596d69f94445f7c5065ffbf7e966bae..89245c160034be5164c66e36103c18065f55e531 100644 (file)
@@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
   if (FD->hasAttr<AsmLabelAttr>())
     Name = getMangledName(D);
   else
-    Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
+    Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
 
   llvm::FunctionType *Ty =
     cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType()));
@@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
   checkTargetFeatures(E, FD);
 
   // See if we have a target specific intrinsic.
-  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
   StringRef Prefix =
       llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
   if (!Prefix.empty()) {
+    StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
     IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
     // NOTE we dont need to perform a compatibility flag check here since the
     // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter the
index 013120a8bd13a43837e64b5a53f41bbb7dad02a1..14a1e5b86a9235d3d698e0465437bd79a249ec02 100644 (file)
@@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
   // Get the decl for the concrete builtin from this, we can tell what the
   // concrete integer type we should convert to is.
   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
-  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
   FunctionDecl *NewBuiltinDecl;
   if (NewBuiltinID == BuiltinID)
     NewBuiltinDecl = FDecl;
   else {
     // Perform builtin lookup to avoid redeclaring it.
+    StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
     DeclarationName DN(&Context.Idents.get(NewBuiltinName));
     LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
     LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
@@ -6263,7 +6263,7 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range,
                             unsigned AbsKind, QualType ArgType) {
   bool EmitHeaderHint = true;
   const char *HeaderName = nullptr;
-  const char *FunctionName = nullptr;
+  StringRef FunctionName;
   if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
     FunctionName = "std::abs";
     if (ArgType->isIntegralOrEnumerationType()) {
@@ -6381,7 +6381,7 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call,
   // Unsigned types cannot be negative.  Suggest removing the absolute value
   // function call.
   if (ArgType->isUnsignedIntegerType()) {
-    const char *FunctionName =
+    StringRef FunctionName =
         IsStdAbs ? "std::abs" : Context.BuiltinInfo.getName(AbsKind);
     Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
     Diag(Call->getExprLoc(), diag::note_remove_abs)