Author: Douglas Yung
Date: 2026-10-11T11:17:53-07:00
New Revision: 57f8109032658668d748312dbcf7862e4fdd4154

URL: 
https://github.com/llvm/llvm-project/commit/57f8109032658668d748312dbcf7862e4fdd4154
DIFF: 
https://github.com/llvm/llvm-project/commit/57f8109032658668d748312dbcf7862e4fdd4154.diff

LOG: Fix GCC warning by enclosing operand with parentheses. (#230939)

PR #174549 made a change to `APValue.h` which causes GCC to emit a
warning like this:
```
clang/include/clang/AST/APValue.h: In static member function ‘static 
clang::DynamicAllocLValue clang::DynamicAllocLValue::getFromOpaqueValue(const 
void*)’:
clang/include/clang/AST/APValue.h:114:54: warning: suggest parentheses around 
‘-’ in operand of ‘&’ [-Wparentheses]
  114 |     V.AllocKind = Combined & (1 << NumAllocKindBits) - 1;
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~
```

>From my build with gcc, this shows up around 1200 times in the logfile
for my build. The problem with this is that for distributed builds, this
forces the build of the file where the warning is emitted to be done
locally which causes a bottleneck. This fixes the source of the warning
so that the build of the files which include `APValue.h` can again be
distributed.

Added: 
    

Modified: 
    clang/include/clang/AST/APValue.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 54e51b7e2fd34..7a69a98702a8c 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -112,7 +112,7 @@ class DynamicAllocLValue {
     DynamicAllocLValue V;
     uintptr_t Combined =
         reinterpret_cast<uintptr_t>(Value) >> NumLowBitsAvailable;
-    V.AllocKind = Combined & (1 << NumAllocKindBits) - 1;
+    V.AllocKind = Combined & ((1 << NumAllocKindBits) - 1);
     V.Index = Combined >> NumAllocKindBits;
     return V;
   }


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to