[all-commits] [llvm/llvm-project] 91ca9a: [Polly] Avoid "using namespace llvm" in public hea...

Michael Kruse via All-commits all-commits at lists.llvm.org
Wed Feb 10 19:00:44 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 91ca9adc9edfba164b579d02c5fe0a7a24cfdd4e
      https://github.com/llvm/llvm-project/commit/91ca9adc9edfba164b579d02c5fe0a7a24cfdd4e
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-02-10 (Wed, 10 Feb 2021)

  Changed paths:
    M polly/include/polly/CodeGen/BlockGenerators.h
    M polly/include/polly/CodeGen/IslAst.h
    M polly/include/polly/CodeGen/IslNodeBuilder.h
    M polly/include/polly/CodeGen/LoopGenerators.h
    M polly/include/polly/CodeGen/LoopGeneratorsGOMP.h
    M polly/include/polly/CodeGen/LoopGeneratorsKMP.h
    M polly/include/polly/DependenceInfo.h
    M polly/include/polly/ForwardOpTree.h
    M polly/include/polly/ScopBuilder.h
    M polly/include/polly/ScopDetection.h
    M polly/include/polly/ScopDetectionDiagnostic.h
    M polly/include/polly/ScopInfo.h
    M polly/include/polly/ScopPass.h
    M polly/include/polly/Support/VirtualInstruction.h
    M polly/lib/CodeGen/IslNodeBuilder.cpp
    M polly/lib/CodeGen/ManagedMemoryRewrite.cpp
    M polly/lib/Transform/ScopInliner.cpp

  Log Message:
  -----------
  [Polly] Avoid "using namespace llvm" in public headers. NFC.

"using namespace" pollutes the namespace of every file that includes
such a header and universally considered a bad thing. Even the variant

    namespace polly {
      using namespace llvm;
    }

(previously used by LoopGenerators.h) imports more symbols than the file
is in control of. The header may include a fixed set of files from LLVM,
but the header itself may by be included together with other headers
from LLVM. For instance, LLVM's MemorySSA.h and Polly's ScopInfo.h both
declare a class 'MemoryAccess' which may conflict.

Instead of prefixing everything in Polly's header files, this patch adds
'using' statements to import only the symbols that are actually
referenced in Polly. This approach is also used by MLIR to import
commonly used symbols into the mlir namespace.

This patch also puts the symbols declared in IslNodeBuilder.h into the
Polly namespace to also be able to use the imported symbols.




More information about the All-commits mailing list