diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-18 15:29:05 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-18 15:29:05 +0000 |
commit | f22856a415bee906e638a78516fcd986469b0dca (patch) | |
tree | bd47f08c4f572a9aa149dbb3d0af202fd75c04cf /clang/lib/Sema/Sema.cpp | |
parent | 0ea96eba43922f0020000d5492004e81f36a9817 (diff) | |
download | llvm-f22856a415bee906e638a78516fcd986469b0dca.zip llvm-f22856a415bee906e638a78516fcd986469b0dca.tar.gz llvm-f22856a415bee906e638a78516fcd986469b0dca.tar.bz2 |
Remove OpenCL-specific type keywords and specifiers
This commit kills off custom type specifier and keyword handling of OpenCL C
data types.
Although the OpenCL spec describes them as keywords, we can handle them more
elegantly as predefined types. This should provide better error correction and
code completion as well as simplifying the implementation.
The primary intention is however to simplify the C/C++ parser and save some
packed bits on AST structures that had been extended in r170432 just for
OpenCL.
llvm-svn: 197578
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 4d01fb0..9a00783 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -120,6 +120,12 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, InitDataSharingAttributesStack(); } +void Sema::addImplicitTypedef(StringRef Name, QualType T) { + DeclarationName DN = &Context.Idents.get(Name); + if (IdResolver.begin(DN) == IdResolver.end()) + PushOnScopeChains(Context.buildImplicitTypedef(T, Name), TUScope); +} + void Sema::Initialize() { // Tell the AST consumer about this Sema object. Consumer.Initialize(Context); @@ -172,6 +178,18 @@ void Sema::Initialize() { PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope); } + // Initialize predefined OpenCL types. + if (PP.getLangOpts().OpenCL) { + addImplicitTypedef("image1d_t", Context.OCLImage1dTy); + addImplicitTypedef("image1d_array_t", Context.OCLImage1dArrayTy); + addImplicitTypedef("image1d_buffer_t", Context.OCLImage1dBufferTy); + addImplicitTypedef("image2d_t", Context.OCLImage2dTy); + addImplicitTypedef("image2d_array_t", Context.OCLImage2dArrayTy); + addImplicitTypedef("image3d_t", Context.OCLImage3dTy); + addImplicitTypedef("sampler_t", Context.OCLSamplerTy); + addImplicitTypedef("event_t", Context.OCLEventTy); + } + DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list"); if (IdResolver.begin(BuiltinVaList) == IdResolver.end()) PushOnScopeChains(Context.getBuiltinVaListDecl(), TUScope); |