From bb23628148f555a4cf71f98c27096a7a804c085c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 11 Nov 2012 07:02:14 +0000 Subject: s/BCPLComment/LineComment/ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167690 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticLexKinds.td | 4 +-- include/clang/Basic/LangOptions.def | 2 +- include/clang/Frontend/LangStandard.h | 6 ++-- include/clang/Frontend/LangStandards.def | 54 +++++++++++++++---------------- include/clang/Lex/Lexer.h | 4 +-- lib/Frontend/CompilerInvocation.cpp | 2 +- lib/Lex/Lexer.cpp | 44 ++++++++++++------------- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 16b1fad770..c6c50ab37b 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -41,9 +41,9 @@ def trigraph_ends_block_comment : Warning<"trigraph ends block comment">, def trigraph_converted : Warning<"trigraph converted to '%0' character">, InGroup; -def ext_multi_line_bcpl_comment : Extension<"multi-line // comment">, +def ext_multi_line_line_comment : Extension<"multi-line // comment">, InGroup; -def ext_bcpl_comment : Extension< +def ext_line_comment : Extension< "// comments are not allowed in this language">, InGroup; def ext_no_newline_eof : Extension<"no newline at end of file">, diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index f4cba24435..7e255c2102 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -56,7 +56,7 @@ BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1, "Objective-C related result type inference") LANGOPT(Trigraphs , 1, 0,"trigraphs") -LANGOPT(BCPLComment , 1, 0, "BCPL-style '//' comments") +LANGOPT(LineComment , 1, 0, "'//' comments") LANGOPT(Bool , 1, 0, "bool, true, and false keywords") LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword") BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers") diff --git a/include/clang/Frontend/LangStandard.h b/include/clang/Frontend/LangStandard.h index a9789158cd..f07cb0234b 100644 --- a/include/clang/Frontend/LangStandard.h +++ b/include/clang/Frontend/LangStandard.h @@ -18,7 +18,7 @@ namespace clang { namespace frontend { enum LangFeatures { - BCPLComment = (1 << 0), + LineComment = (1 << 0), C89 = (1 << 1), C99 = (1 << 2), C11 = (1 << 3), @@ -54,8 +54,8 @@ public: /// getDescription - Get the description of this standard. const char *getDescription() const { return Description; } - /// hasBCPLComments - Language supports '//' comments. - bool hasBCPLComments() const { return Flags & frontend::BCPLComment; } + /// Language supports '//' comments. + bool hasLineComments() const { return Flags & frontend::LineComment; } /// isC89 - Language is a superset of C89. bool isC89() const { return Flags & frontend::C89; } diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Frontend/LangStandards.def index a6b846cc87..10807b7804 100644 --- a/include/clang/Frontend/LangStandards.def +++ b/include/clang/Frontend/LangStandards.def @@ -36,99 +36,99 @@ LANGSTANDARD(c94, "iso9899:199409", LANGSTANDARD(gnu89, "gnu89", "ISO C 1990 with GNU extensions", - BCPLComment | C89 | Digraphs | GNUMode | ImplicitInt) + LineComment | C89 | Digraphs | GNUMode | ImplicitInt) LANGSTANDARD(gnu90, "gnu90", "ISO C 1990 with GNU extensions", - BCPLComment | C89 | Digraphs | GNUMode | ImplicitInt) + LineComment | C89 | Digraphs | GNUMode | ImplicitInt) // C99-ish modes LANGSTANDARD(c99, "c99", "ISO C 1999", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(c9x, "c9x", "ISO C 1999", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(iso9899_1999, "iso9899:1999", "ISO C 1999", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(iso9899_199x, "iso9899:199x", "ISO C 1999", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(gnu99, "gnu99", "ISO C 1999 with GNU extensions", - BCPLComment | C99 | Digraphs | GNUMode | HexFloat) + LineComment | C99 | Digraphs | GNUMode | HexFloat) LANGSTANDARD(gnu9x, "gnu9x", "ISO C 1999 with GNU extensions", - BCPLComment | C99 | Digraphs | GNUMode | HexFloat) + LineComment | C99 | Digraphs | GNUMode | HexFloat) // C11 modes LANGSTANDARD(c11, "c11", "ISO C 2011", - BCPLComment | C99 | C11 | Digraphs | HexFloat) + LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(c1x, "c1x", "ISO C 2011", - BCPLComment | C99 | C11 | Digraphs | HexFloat) + LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(iso9899_2011, "iso9899:2011", "ISO C 2011", - BCPLComment | C99 | C11 | Digraphs | HexFloat) + LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(iso9899_201x, "iso9899:2011", "ISO C 2011", - BCPLComment | C99 | C11 | Digraphs | HexFloat) + LineComment | C99 | C11 | Digraphs | HexFloat) LANGSTANDARD(gnu11, "gnu11", "ISO C 2011 with GNU extensions", - BCPLComment | C99 | C11 | Digraphs | GNUMode | HexFloat) + LineComment | C99 | C11 | Digraphs | GNUMode | HexFloat) LANGSTANDARD(gnu1x, "gnu1x", "ISO C 2011 with GNU extensions", - BCPLComment | C99 | C11 | Digraphs | GNUMode | HexFloat) + LineComment | C99 | C11 | Digraphs | GNUMode | HexFloat) // C++ modes LANGSTANDARD(cxx98, "c++98", "ISO C++ 1998 with amendments", - BCPLComment | CPlusPlus | Digraphs) + LineComment | CPlusPlus | Digraphs) LANGSTANDARD(cxx03, "c++03", "ISO C++ 1998 with amendments", - BCPLComment | CPlusPlus | Digraphs) + LineComment | CPlusPlus | Digraphs) LANGSTANDARD(gnucxx98, "gnu++98", "ISO C++ 1998 with amendments and GNU extensions", - BCPLComment | CPlusPlus | Digraphs | GNUMode) + LineComment | CPlusPlus | Digraphs | GNUMode) LANGSTANDARD(cxx0x, "c++0x", "ISO C++ 2011 with amendments", - BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs) + LineComment | CPlusPlus | CPlusPlus0x | Digraphs) LANGSTANDARD(cxx11, "c++11", "ISO C++ 2011 with amendments", - BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs) + LineComment | CPlusPlus | CPlusPlus0x | Digraphs) LANGSTANDARD(gnucxx0x, "gnu++0x", "ISO C++ 2011 with amendments and GNU extensions", - BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) + LineComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) LANGSTANDARD(gnucxx11, "gnu++11", "ISO C++ 2011 with amendments and GNU extensions", - BCPLComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) + LineComment | CPlusPlus | CPlusPlus0x | Digraphs | GNUMode) LANGSTANDARD(cxx1y, "c++1y", "Working draft for ISO C++ 2014", - BCPLComment | CPlusPlus | CPlusPlus0x | CPlusPlus1y | Digraphs) + LineComment | CPlusPlus | CPlusPlus0x | CPlusPlus1y | Digraphs) LANGSTANDARD(gnucxx1y, "gnu++1y", "Working draft for ISO C++ 2014 with GNU extensions", - BCPLComment | CPlusPlus | CPlusPlus0x | CPlusPlus1y | Digraphs | + LineComment | CPlusPlus | CPlusPlus0x | CPlusPlus1y | Digraphs | GNUMode) // OpenCL LANGSTANDARD(opencl, "cl", "OpenCL 1.0", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(opencl11, "CL1.1", "OpenCL 1.1", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) LANGSTANDARD(opencl12, "CL1.2", "OpenCL 1.2", - BCPLComment | C99 | Digraphs | HexFloat) + LineComment | C99 | Digraphs | HexFloat) // CUDA LANGSTANDARD(cuda, "cuda", "NVIDIA CUDA(tm)", - BCPLComment | CPlusPlus | Digraphs) + LineComment | CPlusPlus | Digraphs) #undef LANGSTANDARD diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index dc7e3534c3..407b644fd7 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -562,9 +562,9 @@ private: bool LexEndOfFile (Token &Result, const char *CurPtr); bool SkipWhitespace (Token &Result, const char *CurPtr); - bool SkipBCPLComment (Token &Result, const char *CurPtr); + bool SkipLineComment (Token &Result, const char *CurPtr); bool SkipBlockComment (Token &Result, const char *CurPtr); - bool SaveBCPLComment (Token &Result, const char *CurPtr); + bool SaveLineComment (Token &Result, const char *CurPtr); bool IsStartOfConflictMarker(const char *CurPtr); bool HandleEndOfConflictMarker(const char *CurPtr); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index d0ff7d2345..8baad79835 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -941,7 +941,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, } const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd); - Opts.BCPLComment = Std.hasBCPLComments(); + Opts.LineComment = Std.hasLineComments(); Opts.C99 = Std.isC99(); Opts.C11 = Std.isC11(); Opts.CPlusPlus = Std.isCPlusPlus(); diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index fa911feed2..c5fe1d879b 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -1898,21 +1898,21 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) { return false; } -// SkipBCPLComment - We have just read the // characters from input. Skip until -// we find the newline character thats terminate the comment. Then update -/// BufferPtr and return. +/// We have just read the // characters from input. Skip until we find the +/// newline character thats terminate the comment. Then update BufferPtr and +/// return. /// /// If we're in KeepCommentMode or any CommentHandler has inserted /// some tokens, this will store the first token and return true. -bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { - // If BCPL comments aren't explicitly enabled for this language, emit an +bool Lexer::SkipLineComment(Token &Result, const char *CurPtr) { + // If Line comments aren't explicitly enabled for this language, emit an // extension warning. - if (!LangOpts.BCPLComment && !isLexingRawMode()) { - Diag(BufferPtr, diag::ext_bcpl_comment); + if (!LangOpts.LineComment && !isLexingRawMode()) { + Diag(BufferPtr, diag::ext_line_comment); // Mark them enabled so we only emit one warning for this translation // unit. - LangOpts.BCPLComment = true; + LangOpts.LineComment = true; } // Scan over the body of the comment. The common case, when scanning, is that @@ -1976,7 +1976,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { } if (!isLexingRawMode()) - Diag(OldPtr-1, diag::ext_multi_line_bcpl_comment); + Diag(OldPtr-1, diag::ext_multi_line_line_comment); break; } } @@ -2005,7 +2005,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { // If we are returning comments as tokens, return this comment as a token. if (inKeepCommentMode()) - return SaveBCPLComment(Result, CurPtr); + return SaveLineComment(Result, CurPtr); // If we are inside a preprocessor directive and we see the end of line, // return immediately, so that the lexer can return this as an EOD token. @@ -2029,9 +2029,9 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { return false; } -/// SaveBCPLComment - If in save-comment mode, package up this BCPL comment in -/// an appropriate way and return it. -bool Lexer::SaveBCPLComment(Token &Result, const char *CurPtr) { +/// If in save-comment mode, package up this Line comment in an appropriate +/// way and return it. +bool Lexer::SaveLineComment(Token &Result, const char *CurPtr) { // If we're not in a preprocessor directive, just return the // comment // directly. FormTokenWithChars(Result, CurPtr, tok::comment); @@ -2039,14 +2039,14 @@ bool Lexer::SaveBCPLComment(Token &Result, const char *CurPtr) { if (!ParsingPreprocessorDirective || LexingRawMode) return true; - // If this BCPL-style comment is in a macro definition, transmogrify it into + // If this Line-style comment is in a macro definition, transmogrify it into // a C-style block comment. bool Invalid = false; std::string Spelling = PP->getSpelling(Result, &Invalid); if (Invalid) return true; - assert(Spelling[0] == '/' && Spelling[1] == '/' && "Not bcpl comment?"); + assert(Spelling[0] == '/' && Spelling[1] == '/' && "Not line comment?"); Spelling[1] = '*'; // Change prefix to "/*". Spelling += "*/"; // add suffix. @@ -2673,8 +2673,8 @@ 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() && - LangOpts.BCPLComment && !LangOpts.TraditionalCPP) { - if (SkipBCPLComment(Result, CurPtr+2)) + LangOpts.LineComment && !LangOpts.TraditionalCPP) { + if (SkipLineComment(Result, CurPtr+2)) return; // There is a token to return. goto SkipIgnoredUnits; } else if (CurPtr[0] == '/' && CurPtr[1] == '*' && !inKeepCommentMode()) { @@ -2959,19 +2959,19 @@ LexNextToken: case '/': // 6.4.9: Comments Char = getCharAndSize(CurPtr, SizeTmp); - if (Char == '/') { // BCPL comment. - // Even if BCPL comments are disabled (e.g. in C89 mode), we generally + if (Char == '/') { // Line comment. + // Even if Line comments are disabled (e.g. in C89 mode), we generally // want to lex this as a comment. There is one problem with this though, // that in one particular corner case, this can change the behavior of the // resultant program. For example, In "foo //**/ bar", C89 would lex - // this as "foo / bar" and langauges with BCPL comments would lex it as + // this as "foo / bar" and langauges with Line 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. // However, we never do this in -traditional-cpp mode. - if ((LangOpts.BCPLComment || + if ((LangOpts.LineComment || getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') && !LangOpts.TraditionalCPP) { - if (SkipBCPLComment(Result, ConsumeChar(CurPtr, SizeTmp, Result))) + if (SkipLineComment(Result, ConsumeChar(CurPtr, SizeTmp, Result))) return; // There is a token to return. // It is common for the tokens immediately after a // comment to be -- cgit v1.2.3