aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/preprocessor.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2021-12-29 12:14:25 -0800
committerPeter Klausler <pklausler@nvidia.com>2022-01-12 16:02:17 -0800
commit0e811d3b66ff85c13629d80c483c5d706eb4d15f (patch)
treea4823c8a5076ea4760b6fdc9aa815995fdae9690 /flang/lib/Parser/preprocessor.cpp
parentb9bc3c107c6cee93cd1a7004142f11741e0225bf (diff)
downloadllvm-0e811d3b66ff85c13629d80c483c5d706eb4d15f.zip
llvm-0e811d3b66ff85c13629d80c483c5d706eb4d15f.tar.gz
llvm-0e811d3b66ff85c13629d80c483c5d706eb4d15f.tar.bz2
[flang] Fix handling of space between # and name in preprocessor stringification
When preprocessing "# ARG" in function-like macro expansion, the preprocessor needs to pop the previously-pushed '#' token from the end of the resulting token sequence after detecting the argument name. The code to do this was just wrong in a couple of ways. Differential Revision: https://reviews.llvm.org/D117148
Diffstat (limited to 'flang/lib/Parser/preprocessor.cpp')
-rw-r--r--flang/lib/Parser/preprocessor.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp
index de85e8e..46b62a4 100644
--- a/flang/lib/Parser/preprocessor.cpp
+++ b/flang/lib/Parser/preprocessor.cpp
@@ -169,8 +169,9 @@ TokenSequence Definition::Apply(
replacement_.TokenAt(prev - 1)[0] ==
'#') { // stringify argument without macro replacement
std::size_t resultSize{result.SizeInTokens()};
- while (resultSize > 0 && result.TokenAt(resultSize - 1).empty()) {
+ while (resultSize > 0 && result.TokenAt(resultSize - 1).IsBlank()) {
result.pop_back();
+ --resultSize;
}
CHECK(resultSize > 0 &&
result.TokenAt(resultSize - 1) == replacement_.TokenAt(prev - 1));