[PATCH] D64608: [OpenCL] Make TableGen'd builtin tables and helper functions static

Tom Stellard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 17:47:57 PDT 2019


tstellar created this revision.
tstellar added reviewers: Pierre, Anastasia.
Herald added a subscriber: yaxunl.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64608

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===================================================================
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -207,7 +207,7 @@
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto &P : SignatureSet) {
     OS << "// " << P.second << "\n";
     for (Record *R : P.first) {
@@ -222,7 +222,7 @@
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto &i : OverloadInfo) {
     StringRef Name = i.first;
     OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair<unsigned, unsigned> isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair<unsigned, unsigned> isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -688,7 +688,7 @@
                                          unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-    OpenCLBuiltinDecl &Decl = OpenCLBuiltins[Index - 1 + i];
+    const OpenCLBuiltinDecl &Decl = OpenCLBuiltins[Index - 1 + i];
     ASTContext &Context = S.Context;
 
     // Ignore this BIF if the version is incorrect.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64608.209383.patch
Type: text/x-patch
Size: 1649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190712/5d296ad9/attachment.bin>


More information about the cfe-commits mailing list