[all-commits] [llvm/llvm-project] 51f343: Frontend: Clarify logic for using the preamble in ...

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Tue Dec 8 12:56:57 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 51f3432f4b5217b35dc2694c6e46d6cfc7defad6
      https://github.com/llvm/llvm-project/commit/51f3432f4b5217b35dc2694c6e46d6cfc7defad6
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
    M clang/lib/Frontend/ASTUnit.cpp

  Log Message:
  -----------
  Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC

Clarify the logic for using the preamble (and overriding the main file
buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas
(`getUniqueID` and `hasSameUniqueID`).  While refactoring the logic,
hoist the check for `Line > 1` and locally check if the filenames are
equal (both to avoid unnecessary `stat` calls) and skip copying out the
filenames to `std::string`.

Besides fewer calls to `stat`, there's no functionality change here.

Differential Revision: https://reviews.llvm.org/D91296




More information about the All-commits mailing list