diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-30 01:52:57 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-30 01:52:57 +0000 |
commit | 17441589c324f88c95e98c7e5d8d5e55cdd7c949 (patch) | |
tree | ab02a8bb2bf16030d81bed1f8e093fc974d19293 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 1105821f55d85c49040934eb842b25e124b01766 (diff) | |
download | llvm-17441589c324f88c95e98c7e5d8d5e55cdd7c949.zip llvm-17441589c324f88c95e98c7e5d8d5e55cdd7c949.tar.gz llvm-17441589c324f88c95e98c7e5d8d5e55cdd7c949.tar.bz2 |
Don't warn about Unicode characters in -E mode.
People use the C preprocessor for things other than C files. Some of them
have Unicode characters. We shouldn't warn about Unicode characters
appearing outside of identifiers in this case.
There's not currently a way for the preprocessor to tell if it's in -E mode,
so I added a new flag, derived from the PreprocessorOutputOptions. This is
only used by the Unicode warnings for now, but could conceivably be used by
other warnings or even behavioral differences later.
<rdar://problem/13107323>
llvm-svn: 173881
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f49f30d..b4b0ddb 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1395,9 +1395,48 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, } static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, - ArgList &Args) { + ArgList &Args, + frontend::ActionKind Action) { using namespace options; - Opts.ShowCPP = !Args.hasArg(OPT_dM); + + switch (Action) { + case frontend::ASTDeclList: + case frontend::ASTDump: + case frontend::ASTDumpXML: + case frontend::ASTPrint: + case frontend::ASTView: + case frontend::EmitAssembly: + case frontend::EmitBC: + case frontend::EmitHTML: + case frontend::EmitLLVM: + case frontend::EmitLLVMOnly: + case frontend::EmitCodeGenOnly: + case frontend::EmitObj: + case frontend::FixIt: + case frontend::GenerateModule: + case frontend::GeneratePCH: + case frontend::GeneratePTH: + case frontend::ParseSyntaxOnly: + case frontend::PluginAction: + case frontend::PrintDeclContext: + case frontend::RewriteObjC: + case frontend::RewriteTest: + case frontend::RunAnalysis: + case frontend::MigrateSource: + Opts.ShowCPP = 0; + break; + + case frontend::DumpRawTokens: + case frontend::DumpTokens: + case frontend::InitOnly: + case frontend::PrintPreamble: + case frontend::PrintPreprocessedInput: + case frontend::RewriteMacros: + case frontend::RunPreprocessorOnly: + Opts.ShowCPP = !Args.hasArg(OPT_dM); + break; + } + Opts.ShowComments = Args.hasArg(OPT_C); Opts.ShowLineMarkers = !Args.hasArg(OPT_P); Opts.ShowMacroComments = Args.hasArg(OPT_CC); @@ -1478,7 +1517,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, // parameters from the function and the "FileManager.h" #include. FileManager FileMgr(Res.getFileSystemOpts()); ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, FileMgr, Diags); - ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args); + ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args, + Res.getFrontendOpts().ProgramAction); ParseTargetArgs(Res.getTargetOpts(), *Args); return Success; |