diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2023-11-13 15:25:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 15:25:10 -0800 |
commit | f2bf44b6ec2aa2ce014446cf3981275cb81f0de3 (patch) | |
tree | 3075f45b8dc7495fc6c624aea2e60a08df76c523 /flang/lib/Parser/preprocessor.cpp | |
parent | 9c1c56a80323291cd47af59d96122ec5bd42ea83 (diff) | |
download | llvm-f2bf44b6ec2aa2ce014446cf3981275cb81f0de3.zip llvm-f2bf44b6ec2aa2ce014446cf3981275cb81f0de3.tar.gz llvm-f2bf44b6ec2aa2ce014446cf3981275cb81f0de3.tar.bz2 |
[flang][preprocessor] Finesse disabling of function-like macros (#71589)
During function-like macro expansion in a standard C/C++ preprocessor,
the macro being expanded is disabled from recursive macro expansion. The
implementation in this compiler's preprocessor, however, was too broad;
the macro expansion needs to be disabled for the "rescanning" phase
only, not for actual argument expansion.
(Also corrects an obsolete comment elsewhere that was noticed during
reduction of an original test case.)
Diffstat (limited to 'flang/lib/Parser/preprocessor.cpp')
-rw-r--r-- | flang/lib/Parser/preprocessor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp index 5af1632..88efcf7 100644 --- a/flang/lib/Parser/preprocessor.cpp +++ b/flang/lib/Parser/preprocessor.cpp @@ -397,9 +397,9 @@ std::optional<TokenSequence> Preprocessor::MacroReplacement( (n + 1 == argStart.size() ? k : argStart[n + 1] - 1) - at}; args.emplace_back(TokenSequence(input, at, count)); } + TokenSequence applied{def->Apply(args, prescanner)}; def->set_isDisabled(true); - TokenSequence replaced{ - ReplaceMacros(def->Apply(args, prescanner), prescanner)}; + TokenSequence replaced{ReplaceMacros(std::move(applied), prescanner)}; def->set_isDisabled(false); if (!replaced.empty()) { ProvenanceRange from{def->replacement().GetProvenanceRange()}; |