[cfe-commits] r39399 - in /cfe/cfe/trunk: Lex/PPExpressions.cpp test/Preprocessor/cxx_true.cpp
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:43:59 PDT 2007
Author: clattner
Date: Wed Jul 11 11:43:58 2007
New Revision: 39399
URL: http://llvm.org/viewvc/llvm-project?rev=39399&view=rev
Log:
'true' in a CPP expression evaluates to 1 when in C++ mode. This implements
test/Preprocessor/cxx_true.cpp
Added:
cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp (with props)
Modified:
cfe/cfe/trunk/Lex/PPExpressions.cpp
Modified: cfe/cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/PPExpressions.cpp?rev=39399&r1=39398&r2=39399&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/cfe/trunk/Lex/PPExpressions.cpp Wed Jul 11 11:43:58 2007
@@ -73,9 +73,10 @@
// keywords are pp-identifiers, so we can't check the kind.
if (IdentifierInfo *II = PeekTok.getIdentifierInfo()) {
// If this identifier isn't 'defined' and it wasn't macro expanded, it turns
- // into a simple 0.
+ // into a simple 0, unless it is the C++ keyword "true", in which case it
+ // turns into "1".
if (II->getPPKeywordID() != tok::pp_defined) {
- Result = 0;
+ Result = II->getTokenID() == tok::kw_true;
Result.setIsUnsigned(false); // "0" is signed intmax_t 0.
PP.LexNonComment(PeekTok);
return false;
Added: cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp?rev=39399&view=auto
==============================================================================
--- cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp (added)
+++ cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp Wed Jul 11 11:43:58 2007
@@ -0,0 +1,13 @@
+/* RUN: clang -E t.cpp -x=c++ | grep block_1 &&
+ RUN: clang -E t.cpp -x=c++ | not grep block_2 &&
+ RUN: clang -E t.cpp -x=c | not grep block
+*/
+
+#if true
+block_1
+#endif
+
+#if false
+block_2
+#endif
+
Propchange: cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/test/Preprocessor/cxx_true.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
More information about the cfe-commits
mailing list