summaryrefslogtreecommitdiffstats
path: root/source/core/slang-char-util.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-03-31 13:11:49 -0400
committerGitHub <noreply@github.com>2021-03-31 13:11:49 -0400
commit5fde038b1a6b3c8b335cd5b380c3ee8d15403052 (patch)
tree27975331c960edc405a5294031fd6a4a79eff964 /source/core/slang-char-util.h
parent5fefb120e0c2469563e937f4ee39b391d7678cdf (diff)
Support for __LINE__ and __FILE__ in preprocessor (#1772)
* #include an absolute path didn't work - because paths were taken to always be relative. * First pass support for __LINE__ and __FILE__. * Test include handling with __FILE__ Fix diagnostic compare when input is empty. * Fix some issues in preprocessor handling of special macros like __LINE__ Add a more complex test. * Use CONCAT2 in tests, because preprocessor doesn't quite get parameter expansion correct. * Make __FILE__ and __LINE__ behave more like Clang/Gcc. * A test for preprocessor bug. * Fix __LINE__ and __FILE__ in macro expansion, should be initiating location. * Fix some comments. * Small tidy up around builtin macros. * Small improvements for macro type names. Escape found paths.
Diffstat (limited to 'source/core/slang-char-util.h')
-rw-r--r--source/core/slang-char-util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/source/core/slang-char-util.h b/source/core/slang-char-util.h
index 810cde0b1..2434697d4 100644
--- a/source/core/slang-char-util.h
+++ b/source/core/slang-char-util.h
@@ -17,6 +17,7 @@ struct CharUtil
Digit = 0x04, ///< 0-9
HorizontalWhitespace = 0x08, ///< Whitespace that can appear horizontally (ie excluding CR/LF)
HexDigit = 0x10, ///< 0-9, a-f, A-F
+ VerticalWhitespace = 0x20, ///< \n \r
};
};
@@ -24,6 +25,8 @@ struct CharUtil
SLANG_FORCE_INLINE static bool isLower(char c) { return c >= 'a' && c <= 'z'; }
SLANG_FORCE_INLINE static bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
SLANG_FORCE_INLINE static bool isHorizontalWhitespace(char c) { return c == ' ' || c == '\t'; }
+ SLANG_FORCE_INLINE static bool isVerticalWhitespace(char c) { return c == '\n' || c == '\r'; }
+ SLANG_FORCE_INLINE static bool isWhitespace(char c) { return (getFlags(c) & (Flag::HorizontalWhitespace | Flag::VerticalWhitespace)) != 0; }
/// True if it's alpha
SLANG_FORCE_INLINE static bool isAlpha(char c) { return (getFlags(c) & (Flag::Upper | Flag::Lower)) != 0; }
@@ -38,6 +41,7 @@ struct CharUtil
/// Given a character return the upper case equivalent
SLANG_FORCE_INLINE static char toUpper(char c) { return (c >= 'a' && c <= 'z') ? (c -'a' + 'A') : c; }
+
struct CharFlagMap
{
Flags flags[0x100];