[flang-commits] [flang] [flang] Ignore empty keyword macros before directives (PR #130333)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Mar 7 12:16:19 PST 2025


================
@@ -1463,18 +1485,18 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
   *sp = '\0';
   if (const char *ss{IsCompilerDirectiveSentinel(
           sentinel, static_cast<std::size_t>(sp - sentinel))}) {
-    std::size_t payloadOffset = p - start;
-    return {LineClassification{
-        LineClassification::Kind::CompilerDirective, payloadOffset, ss}};
+    return {
+        LineClassification{LineClassification::Kind::CompilerDirective, 0, ss}};
   }
   return std::nullopt;
 }
 
 std::optional<Prescanner::LineClassification>
 Prescanner::IsFreeFormCompilerDirectiveLine(const char *start) const {
-  if (const char *p{SkipWhiteSpace(start)}; p && *p++ == '!') {
+  if (const char *p{SkipWhiteSpaceIncludingEmptyMacros(start)};
+      p && *p++ == '!') {
     if (auto maybePair{IsCompilerDirectiveSentinel(p)}) {
----------------
klausler wrote:

>From prescan.h: `// 'first' is the sentinel, 'second' is beginning of payload`.

https://github.com/llvm/llvm-project/pull/130333


More information about the flang-commits mailing list