[cfe-commits] r39906 - in /cfe/trunk: Basic/SourceManager.cpp Lex/LiteralSupport.cpp TODO.txt clang.xcodeproj/project.pbxproj test/Lexer/constants.c
Chris Lattner
sabre at nondot.org
Sun Jul 15 23:55:02 PDT 2007
Author: lattner
Date: Mon Jul 16 01:55:01 2007
New Revision: 39906
URL: http://llvm.org/viewvc/llvm-project?rev=39906&view=rev
Log:
Make octal constant lexing use AdvanceToTokenCharacter to give more
accurate diagnostics. For test/Lexer/comments.c we now emit:
int x = 000000080; /* expected-error {{invalid digit}} */
^
constants.c:7:4: error: invalid digit '8' in octal constant
00080; /* expected-error {{invalid digit}} */
^
The last line is due to an escaped newline. The full line looks like:
int y = 0000\
00080; /* expected-error {{invalid digit}} */
Previously, we emitted:
constants.c:4:9: error: invalid digit '8' in octal constant
int x = 000000080; /* expected-error {{invalid digit}} */
^
constants.c:6:9: error: invalid digit '8' in octal constant
int y = 0000\
^
which isn't too bad, but the new way is better for the user,
regardless of whether there is an escaped newline or not.
All the other lexer-related diagnostics should switch over
to using AdvanceToTokenCharacter where appropriate. Help
wanted :).
This implements test/Lexer/constants.c.
Added:
cfe/trunk/test/Lexer/constants.c
Modified:
cfe/trunk/Basic/SourceManager.cpp
cfe/trunk/Lex/LiteralSupport.cpp
cfe/trunk/TODO.txt
cfe/trunk/clang.xcodeproj/project.pbxproj
Modified: cfe/trunk/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceManager.cpp?rev=39906&r1=39905&r2=39906&view=diff
==============================================================================
--- cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/trunk/Basic/SourceManager.cpp Mon Jul 16 01:55:01 2007
@@ -339,7 +339,6 @@
return getFilePos(Loc);
}
-
/// PrintStats - Print statistics to stderr.
///
void SourceManager::PrintStats() const {
Modified: cfe/trunk/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=39906&r1=39905&r2=39906&view=diff
==============================================================================
--- cfe/trunk/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/Lex/LiteralSupport.cpp Mon Jul 16 01:55:01 2007
@@ -14,8 +14,9 @@
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
-#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringExtras.h"
using namespace clang;
@@ -261,6 +262,7 @@
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
+ TokLoc = PP.AdvanceToTokenCharacter(TokLoc, s-begin);
Diag(TokLoc, diag::err_invalid_octal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
Modified: cfe/trunk/TODO.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/TODO.txt?rev=39906&r1=39905&r2=39906&view=diff
==============================================================================
--- cfe/trunk/TODO.txt (original)
+++ cfe/trunk/TODO.txt Mon Jul 16 01:55:01 2007
@@ -22,6 +22,8 @@
00080;
^
+This specific diagnostic is implemented, but others should be updated.
+
//===---------------------------------------------------------------------===//
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=39906&r1=39905&r2=39906&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Mon Jul 16 01:55:01 2007
@@ -189,7 +189,7 @@
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
- 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
Added: cfe/trunk/test/Lexer/constants.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/constants.c?rev=39906&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/constants.c (added)
+++ cfe/trunk/test/Lexer/constants.c Mon Jul 16 01:55:01 2007
@@ -0,0 +1,8 @@
+/* RUN: clang -parse-ast-check %s
+ */
+
+int x = 000000080; /* expected-error {{invalid digit}} */
+
+int y = 0000\
+00080; /* expected-error {{invalid digit}} */
+
More information about the cfe-commits
mailing list