[flang-commits] [flang] [flang][DRAFT] DON'T REVIEW - continuation of ACC COMMON work (PR #162893)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 16 11:22:24 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- flang/include/flang/Semantics/scope.h flang/lib/Semantics/resolve-directives.cpp flang/lib/Semantics/resolve-names.cpp flang/lib/Semantics/scope.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/include/flang/Semantics/scope.h b/flang/include/flang/Semantics/scope.h
index c8cc04fdc..be515a26a 100644
--- a/flang/include/flang/Semantics/scope.h
+++ b/flang/include/flang/Semantics/scope.h
@@ -192,7 +192,7 @@ public:
   bool AddCommonBlockUse(const SourceName &name, Symbol &cbSymbol);
 
   // Find COMMON block that is not USE-associated in the current scope
-  Symbol *FindCommonBlock(const SourceName &name) const  {
+  Symbol *FindCommonBlock(const SourceName &name) const {
     if (const auto it{commonBlocks_.find(name)}; it != commonBlocks_.end()) {
       return &*it->second;
     }
@@ -200,8 +200,9 @@ public:
   }
 
   // Find USE-associated COMMON block in the current scope
-  Symbol *FindCommonBlockUse(const SourceName &name) const  {
-    if (const auto it{useCommonBlocks_.find(name)}; it != useCommonBlocks_.end()) {
+  Symbol *FindCommonBlockUse(const SourceName &name) const {
+    if (const auto it{useCommonBlocks_.find(name)};
+        it != useCommonBlocks_.end()) {
       return &*it->second;
     }
     return nullptr;
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 0991c3607..74089d6ad 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1732,7 +1732,8 @@ Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
   if (!name) {
     return nullptr;
   }
-  if (auto *cb{GetContext().scope.FindCommonBlockInSurroundingScopes(name->source)}) {
+  if (auto *cb{GetContext().scope.FindCommonBlockInSurroundingScopes(
+          name->source)}) {
     name->symbol = cb;
     return cb;
   }
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 2a4f163ca..430d68c35 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3630,7 +3630,8 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
   // Go through the list of COMMON block symbols in the module scope and add
   // their USE association to the current scope's USE-associated COMMON blocks.
   for (const auto &[name, symbol] : useModuleScope_->commonBlocks()) {
-    if (auto *localCB{currScope().FindCommonBlockInSurroundingScopes(name)}; !localCB) {
+    if (auto *localCB{currScope().FindCommonBlockInSurroundingScopes(name)};
+        !localCB) {
       // Make a symbol, but don't add it to the Scope, since it needs to
       // be added to the USE-associated COMMON blocks
       localCB = &currScope().MakeSymbol(
diff --git a/flang/lib/Semantics/scope.cpp b/flang/lib/Semantics/scope.cpp
index 4fcdce2c4..c407e0f6e 100644
--- a/flang/lib/Semantics/scope.cpp
+++ b/flang/lib/Semantics/scope.cpp
@@ -154,10 +154,11 @@ Symbol &Scope::MakeCommonBlock(SourceName name, SourceName location) {
   }
 }
 
-Symbol *Scope::FindCommonBlockInSurroundingScopes(const SourceName &name) const {
-  if (Symbol *cb{FindCommonBlock(name)}) {
+Symbol *Scope::FindCommonBlockInSurroundingScopes(
+    const SourceName &name) const {
+  if (Symbol * cb{FindCommonBlock(name)}) {
     return cb;
-  } else if (Symbol *cb{FindCommonBlockUse(name)}) {
+  } else if (Symbol * cb{FindCommonBlockUse(name)}) {
     return &cb->GetUltimate();
   } else if (IsSubmodule()) {
     if (const Scope *parent{

``````````

</details>


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


More information about the flang-commits mailing list