Add -f[no-]declspec to control recognition of __declspec as a keyword

In versions of clang prior to r238238, __declspec was recognized as a keyword in
all modes.  It was then changed to only be enabled when Microsoft or Borland
extensions were enabled (and for CUDA, as a temporary measure).  There is a
desire to support __declspec in Playstation code, and possibly other
environments.  This commit adds a command-line switch to allow explicit
enabling/disabling of the recognition of __declspec as a keyword.  Recognition
is enabled by default in Microsoft, Borland, CUDA, and PS4 environments, and
disabled in all other environments.

Patch by Warren Ristow!

llvm-svn: 249279
This commit is contained in:
Saleem Abdulrasool
2015-10-04 17:51:05 +00:00
parent f9d71a5439
commit d170c4b57a
11 changed files with 68 additions and 10 deletions

View File

@@ -220,10 +220,7 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
AddKeyword("__unknown_anytype", tok::kw___unknown_anytype, KEYALL,
LangOpts, *this);
// FIXME: __declspec isn't really a CUDA extension, however it is required for
// supporting cuda_builtin_vars.h, which uses __declspec(property). Once that
// has been rewritten in terms of something more generic, remove this code.
if (LangOpts.CUDA)
if (LangOpts.DeclSpecKeyword)
AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
}