diff options
author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-12-18 10:13:51 +0000 |
---|---|---|
committer | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-12-18 10:13:51 +0000 |
commit | 308b8b76ceee805c964faf9f2176e3e05532a45b (patch) | |
tree | 0b77330d21312d2cf4bd8b9113e0d3e55af29f39 /clang/lib/Sema/SemaLookup.cpp | |
parent | 364b8f5fbe0ac496931dcbd6f0493781f0677e82 (diff) | |
download | bcm5719-llvm-308b8b76ceee805c964faf9f2176e3e05532a45b.tar.gz bcm5719-llvm-308b8b76ceee805c964faf9f2176e3e05532a45b.zip |
[OpenCL] Add builtin function extension handling
Provide a mechanism to attach OpenCL extension information to builtin
functions, so that their use can be restricted according to the
extension(s) the builtin is part of.
Patch by Pierre Gondois and Sven van Haastregt.
Differential Revision: https://reviews.llvm.org/D71476
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index d9b6cb6a921..0ed51de0cc1 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -739,6 +739,18 @@ static void GetOpenCLBuiltinFctOverloads( } } +/// Add extensions to the function declaration. +/// \param S (in/out) The Sema instance. +/// \param BIDecl (in) Description of the builtin. +/// \param FDecl (in/out) FunctionDecl instance. +static void AddOpenCLExtensions(Sema &S, const OpenCLBuiltinStruct &BIDecl, + FunctionDecl *FDecl) { + // Fetch extension associated with a function prototype. + StringRef E = FunctionExtensionTable[BIDecl.Extension]; + if (E != "") + S.setOpenCLExtensionForDecl(FDecl, E); +} + /// When trying to resolve a function name, if isOpenCLBuiltin() returns a /// non-null <Index, Len> pair, then the name is referencing an OpenCL /// builtin function. Add all candidate signatures to the LookUpResult. @@ -827,6 +839,8 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR, if (!S.getLangOpts().OpenCLCPlusPlus) NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context)); + AddOpenCLExtensions(S, OpenCLBuiltin, NewOpenCLBuiltin); + LR.addDecl(NewOpenCLBuiltin); } } |