Henry
Henry

Reputation: 587

How does LLVM distinguish between clang and clang++ commands?

I'm exploring the LLVM/Clang source code and interested in understanding how LLVM distinguishes between clang and clang++ commands, knowing that clang++ is often considered an alias of clang. Which files or functions in the llvm-project/clang directory handle this analysis? Any guidance on where to look for this specific logic would be appreciated.

Thank you!

Upvotes: 0

Views: 27

Answers (1)

Henry
Henry

Reputation: 587

I finally found it in ToolChain.cpp

  static const DriverSuffix DriverSuffixes[] = {
  {"clang", nullptr},
  {"clang++", "--driver-mode=g++"},
  {"clang-c++", "--driver-mode=g++"},
  {"clang-cc", nullptr},
  {"clang-cpp", "--driver-mode=cpp"},
  {"clang-g++", "--driver-mode=g++"},
  {"clang-gcc", nullptr},
  {"clang-cl", "--driver-mode=cl"},
  {"cc", nullptr},
  {"cpp", "--driver-mode=cpp"},
  {"cl", "--driver-mode=cl"},
  {"++", "--driver-mode=g++"},
  {"flang", "--driver-mode=flang"},
  {"clang-dxc", "--driver-mode=dxc"},
  };

Upvotes: 0

Related Questions