aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/preprocessor.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2025-03-10 13:21:10 -0700
committerGitHub <noreply@github.com>2025-03-10 13:21:10 -0700
commitc1898522180f76376167aaab8c0f07afe9e3fef5 (patch)
tree0d8885d1161827ebd4d133b877b46cf37b708053 /flang/lib/Parser/preprocessor.cpp
parent8227f2a35aef0abebf0e2914795b668845a90169 (diff)
downloadllvm-c1898522180f76376167aaab8c0f07afe9e3fef5.zip
llvm-c1898522180f76376167aaab8c0f07afe9e3fef5.tar.gz
llvm-c1898522180f76376167aaab8c0f07afe9e3fef5.tar.bz2
[flang] Ignore empty keyword macros before directives (#130333)
Ignore any keyword macros with empty directives that might appear before a compiler directive. Fixes https://github.com/llvm/llvm-project/issues/126459.
Diffstat (limited to 'flang/lib/Parser/preprocessor.cpp')
-rw-r--r--flang/lib/Parser/preprocessor.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp
index 6c257f5..7e6a1c2 100644
--- a/flang/lib/Parser/preprocessor.cpp
+++ b/flang/lib/Parser/preprocessor.cpp
@@ -842,6 +842,15 @@ bool Preprocessor::IsNameDefined(const CharBlock &token) {
return definitions_.find(token) != definitions_.end();
}
+bool Preprocessor::IsNameDefinedEmpty(const CharBlock &token) {
+ if (auto it{definitions_.find(token)}; it != definitions_.end()) {
+ const Definition &def{it->second};
+ return !def.isFunctionLike() && def.replacement().SizeInChars() == 0;
+ } else {
+ return false;
+ }
+}
+
bool Preprocessor::IsFunctionLikeDefinition(const CharBlock &token) {
auto it{definitions_.find(token)};
return it != definitions_.end() && it->second.isFunctionLike();