[PATCH] D150966: [clang] Don't define predefined macros multiple times

John Brawn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 19 07:40:52 PDT 2023


john.brawn created this revision.
john.brawn added reviewers: aaron.ballman, thakis, arichardson, pratlucas.
Herald added subscribers: luke, abrachet, frasercrmck, phosek, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, fedor.sergeev, kristof.beyls, krytarowski, dylanmckay, dschuff.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay, aheejin.
Herald added a project: clang.

Fix several instances of macros being defined multiple times in several targets. Most of these are just simple duplication in a TargetInfo or OSTargetInfo of things already defined in InitializePredefinedMacros or InitializeStandardPredefinedMacros, but there are a few that aren't:

- AArch64 defines a couple of feature macros for armv8.1a that are handled generically by getTargetDefines.
- CSKY needs to take care when CPUName and ArchName are the same.
- Many os/target combinations result in __ELF__ being defined twice. Instead define __ELF__ just once in InitPreprocessor based on the Triple, which already knows what the object format is based on os and target.

These changes shouldn't change the final result of which macros are defined, with the exception of the changes to __ELF__ where if you explicitly specify the object type in the triple then this affects if __ELF__ is defined, e.g. --target=i686-windows-elf results in it being defined where it wasn't before, but this is more accurate as an ELF file is in fact generated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150966

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/lib/Basic/Targets/Le64.cpp
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros-no-warnings.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150966.523757.patch
Type: text/x-patch
Size: 27548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230519/4cf661d3/attachment-0001.bin>


More information about the cfe-commits mailing list