[cfe-dev] math.h on Windows
Chris Lattner
clattner at apple.com
Wed Oct 28 23:22:08 PDT 2009
On Oct 28, 2009, at 11:08 AM, John Thompson wrote:
> Hi Chris and Doug,
>
> Here's a patch with my initial stab at "__has_include" and
> "__has_include_next", along with a test for it (has_include.c) and
> the modified stdint.h.
Awesome, thanks for working on this John, some thoughts:
* these should be documented in the clang language extensions document.
+++ include/clang/Basic/TokenKinds.def (working copy)
@@ -83,6 +83,10 @@
PPKEYWORD(assert)
PPKEYWORD(unassert)
+// Clang Extensions.
+PPKEYWORD(__has_include)
+PPKEYWORD(__has_include_next)
Can this be implemented like __has_builtin is? This is actually
registered as a macro (in lib/Lex/PPMacroExpansion.cpp) which allows
people to do things like:
#if defined(__has_builtin) && __has_builtin(__builtin_foo)
for example.
__has_include "stdio.h"
I think it is best to require ()'s, for similarity with __has_builtin
and to allow people without this feature to #define it away.
@@ -244,9 +244,14 @@
return CurPPLexer == L;
}
- /// getCurrentLexer - Return the current file lexer being lexed
from. Note
+ /// getCurrentLexer - Return the current lexer being lexed from.
Note
/// that this ignores any potentially active macro expansions and
_Pragma
/// expansions going on at the time.
+ PreprocessorLexer *getCurrentLexer() const { return CurPPLexer; }
+
+ /// getCurrentFileLexer - Return the current file lexer being lexed
from. Note
+ /// that this ignores any potentially active macro expansions and
_Pragma
+ /// expansions going on at the time.
PreprocessorLexer *getCurrentFileLexer() const;
Please apply separately.
/// This code concatenates and consumes tokens up to the '>' token.
It returns
/// false if the > was found, otherwise it returns true if it finds
and consumes
/// the EOM marker.
-static bool ConcatenateIncludeName(llvm::SmallVector<char, 128>
&FilenameBuffer,
- Preprocessor &PP) {
+bool Preprocessor::ConcatenateIncludeName(
This set of changes is ok with me, please apply it separately to
mainline.
+/// EvaluateDefined - Process a 'defined(sym)' expression.
+static bool EvaluateDefined(PPValue &Result, Token &PeekTok,
+ DefinedTracker &DT, bool ValueLive, Preprocessor &PP) {
Splitting this out makes sense to me, but please do it as a separate
commit.
>
> Since these are Clang-specific keywords (I think), perhaps they
> should be disabled in some circumstances (i.e. language mode), but
> I'm not sure how, and I haven't look much into it yet how it is done
> elsewhere in the code.
This can be done by just not registering the 'magic' macros in no-
extensions mode. Please apply the pieces above as independent
patches, and try restructuring your approach around magic macros to
follow the lead of __has_feature and __has_builtin, sending in that
patch for review.
Thanks again John,
-Chris
More information about the cfe-dev
mailing list