[PATCH] D108560: [clang-tidy] Add support for `NOLINTBEGIN` ... `NOLINTEND` comments

Salman Javed via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 8 01:47:38 PST 2021


salman-javed-nz added a comment.

Hi, just giving a progress update. This is just a early heads-up - no action needed from you at this stage.

I have a rough prototype that seems promising. The big-O/time complexity is no longer dependent on the number of headers being included and the number of diagnostics being raised. I need to tidy up and refactor the code before sharing with you but to give an early indication of the path I'm taking, it's essentially:

  struct NolintBlock {
    SourceLocation BeginLoc;
    SourceLocation EndLoc;
    std::string Checks;
  };
  
  // Need to keep a cache of every NOLINT block seen, not only in the current file
  // but in any other file seen during this run of the program. We may be context
  // switching between files (if there is a check violation in a macro in an
  // #included file, for instance), and we don't want to be starting from scratch
  // each time.
  some_kind_of_map<FileID, SmallVector<NolintBlock>> NolintBlocks;
  // Performance of each type of map class is still to be evaluated...
  
  bool lineIsMarkedWithNOLINT(/* ... */) {
    // These two `if` statements will more or less be the same as they are now:
    //   If NOLINT statement found on this line, return true
    //   If NOLINTNEXTLINE statement found on previous line, return true
  
    // If no cache for the file exists, generate it (warning: heavy operation)
    
    // For NolintBlock in NolintBlocks[FileID]:
    //   if NolintBlock.StartLoc < Loc < NolintBlock.EndLoc:
    //      return true
    // Return false
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108560/new/

https://reviews.llvm.org/D108560



More information about the cfe-commits mailing list