diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-03-18 21:23:38 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-03-18 21:23:38 +0000 |
commit | 1057f86d0e538bcd619a028171e4a1634227f60d (patch) | |
tree | 87f228e5c8307109f16c0dd29fcd948e45426597 /clang/lib | |
parent | 59721e3238b78938602679eb8cad74efe6c49215 (diff) | |
download | bcm5719-llvm-1057f86d0e538bcd619a028171e4a1634227f60d.tar.gz bcm5719-llvm-1057f86d0e538bcd619a028171e4a1634227f60d.zip |
Lexer: Add extremely limited support for -traditional-cpp, ignoring BCPL
comments.
llvm-svn: 127910
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 31fcee2de88..9d9c99611cf 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -574,6 +574,8 @@ static void LangOptsToArgs(const LangOptions &Opts, Res.push_back("-fcxx-exceptions"); if (Opts.SjLjExceptions) Res.push_back("-fsjlj-exceptions"); + if (Opts.TraditionalCPP) + Res.push_back("-traditional-cpp"); if (!Opts.RTTI) Res.push_back("-fno-rtti"); if (Opts.MSBitfields) @@ -1442,6 +1444,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions); Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions); Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions); + Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp); Opts.RTTI = !Args.hasArg(OPT_fno_rtti); Opts.Blocks = Args.hasArg(OPT_fblocks); diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index b511421ee77..6f3d611fb07 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -2091,7 +2091,7 @@ LexNextToken: // If the next token is obviously a // or /* */ comment, skip it efficiently // too (without going through the big switch stmt). if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode() && - Features.BCPLComment) { + Features.BCPLComment && !Features.TraditionalCPP) { if (SkipBCPLComment(Result, CurPtr+2)) return; // There is a token to return. goto SkipIgnoredUnits; @@ -2280,8 +2280,10 @@ LexNextToken: // this as "foo / bar" and langauges with BCPL comments would lex it as // "foo". Check to see if the character after the second slash is a '*'. // If so, we will lex that as a "/" instead of the start of a comment. - if (Features.BCPLComment || - getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') { + // However, we never do this in -traditional-cpp mode. + if ((Features.BCPLComment || + getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') && + !Features.TraditionalCPP) { if (SkipBCPLComment(Result, ConsumeChar(CurPtr, SizeTmp, Result))) return; // There is a token to return. |