[llvm] [NFC] Add `const` for readability (PR #116611)
    Piotr Fusik via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Nov 21 11:04:56 PST 2024
    
    
  
================
@@ -581,30 +581,30 @@ class InnerLoopVectorizer {
   virtual void printDebugTracesAtEnd() {}
 
   /// The original loop.
-  Loop *OrigLoop;
+  Loop *const OrigLoop;
 
   /// A wrapper around ScalarEvolution used to add runtime SCEV checks. Applies
   /// dynamic knowledge to simplify SCEV expressions and converts them to a
   /// more usable form.
   PredicatedScalarEvolution &PSE;
 
   /// Loop Info.
-  LoopInfo *LI;
+  LoopInfo *const LI;
----------------
pfusik wrote:
I'm not a fan of putting `const` everywhere, for example on local variables and parameters.
But I see value in saying that a member variable is not mutated after construction. I'm surprised that you weren't aware of this meaning of `const` !
Also, to be clear, it is not my goal to add `const`s here and there, but to understand the code.
https://github.com/llvm/llvm-project/pull/116611
    
    
More information about the llvm-commits
mailing list