[flang-commits] [clang] [flang] [flang][nfc] Refactor linker invocation logic (PR #75534)

Andrzej WarzyƄski via flang-commits flang-commits at lists.llvm.org
Fri Dec 15 07:04:29 PST 2023


================
@@ -1116,73 +1116,87 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
   return true;
 }
 
+/// Determines if --whole-archive is active in the list of arguments.
+static bool isWholeArchivePresent(const ArgList &Args) {
+  bool WholeArchiveActive = false;
+  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
+    if (Arg) {
----------------
banach-space wrote:

I find this to be a borderline case, so just opted for whatever feels more readable :)

Some relevant bits from the [coding standard](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements)

> However, braces should be used in cases where the omission of braces harm the readability and maintainability of the code.

```cpp
// Use braces on the outer block because there are more than two levels of
// nesting.
if (isa<FunctionDecl>(D)) {
  for (auto *A : D.attrs())
    for (ssize_t i : llvm::seq<ssize_t>(count))
      handleAttrOnDecl(D, A, i);
}
```

```cpp
// Use braces on the outer block because of a nested `if`; otherwise the
// compiler would warn: `add explicit braces to avoid dangling else`
if (auto *D = dyn_cast<FunctionDecl>(D)) {
  if (shouldProcess(D))
    handleVarDecl(D);
  else
    markAsIgnored(D);
}
```

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


More information about the flang-commits mailing list