[all-commits] [llvm/llvm-project] c9fbab: [ASTMatcher] Fix redundant macro expansion checks ...

mandymi via All-commits all-commits at lists.llvm.org
Tue Dec 3 08:23:17 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c9fbabfdc92f12b2b0148762e6e789157a172e4d
      https://github.com/llvm/llvm-project/commit/c9fbabfdc92f12b2b0148762e6e789157a172e4d
  Author: mandymi <131526806+mandymimi at users.noreply.github.com>
  Date:   2024-12-03 (Tue, 03 Dec 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/ASTMatchers/ASTMatchersInternal.cpp

  Log Message:
  -----------
  [ASTMatcher] Fix redundant macro expansion checks in getExpansionLocOfMacro (#117143)

A performance issue was descibed in #114521 

**Root Cause**: The function getExpansionLocOfMacro is responsible for
finding the expansion location of macros. When dealing with macro
parameters, it recursively calls itself to check the expansion of macro
arguments. This recursive logic redundantly checks previous macro
expansions, leading to significant performance degradation when macros
are heavily nested.
Solution
**Modification**: Track already processed macros during recursion.
Implementation Details:
Introduced a data structure to record processed macros.
Before each recursive call, check if the macro has already been
processed to avoid redundant calculations.
**Testing**: 
1. refer to #114521 
Finder->addMatcher(expr(isExpandedFromMacro("NULL")).bind("E"), this);
run clang-tidy on freecad/src/Mod/Path/App/AreaPyImp.cpp 
clang-tidy src/Mod/Path/App/AreaPyImp.cpp -checks=-*,testchecker
-p=build/compile_commands.json
checker runs normally
2. check-clang-unit pass



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list