diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-04-17 20:17:31 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-04-17 20:17:31 +0000 |
commit | e03aa55bfdf5f8f63c1c6b4240b71e1027750d0b (patch) | |
tree | 605c935620f5809952026cccc0a159a7239c4e89 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 11e5140db94dc3f27108f313135d0664d3ccd421 (diff) | |
download | bcm5719-llvm-e03aa55bfdf5f8f63c1c6b4240b71e1027750d0b.tar.gz bcm5719-llvm-e03aa55bfdf5f8f63c1c6b4240b71e1027750d0b.zip |
Add support for '-fgnu-keywords' and '-fasm' to Clang's driver. They are not
implemented precisely the same as GCC, but the distinction GCC makes isn't
useful to represent. This allows parsing code which uses GCC-specific keywords
('asm', etc.) without parsing in a fully GNU mode.
llvm-svn: 101667
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index cb227b7bf71..932481f87f6 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -473,6 +473,10 @@ static void LangOptsToArgs(const LangOptions &Opts, // BCPLComment, C99, CPlusPlus0x, Digraphs, GNUInline, ImplicitInt, GNUMode if (Opts.DollarIdents) Res.push_back("-fdollars-in-identifiers"); + if (Opts.GNUMode && !Opts.GNUKeywords) + Res.push_back("-fno-gnu-keywords"); + if (!Opts.GNUMode && Opts.GNUKeywords) + Res.push_back("-fgnu-keywords"); if (Opts.Microsoft) Res.push_back("-fms-extensions"); if (Opts.ObjCNonFragileABI) @@ -1151,6 +1155,14 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, // OpenCL and C++ both have bool, true, false keywords. Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; + // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension + // keywords. This behavior is provided by GCC's poorly named '-fasm' flag, + // while a subset (the non-C++ GNU keywords) is provided by GCC's + // '-fgnu-keywords'. Clang conflates the two for simplicity under the single + // name, as it doesn't seem a useful distinction. + Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords, + Opts.GNUMode); + if (Opts.CPlusPlus) Opts.CXXOperatorNames = !Args.hasArg(OPT_fno_operator_names); |