[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 13 06:47:56 PDT 2018


dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Hal requested splitting the patch in two, since the two features are separable, but they both still seem to be here.  Perhaps start with the prefix patch?



================
Comment at: include/clang/Driver/Options.td:828
 
+def FILE_prefix_to_remove : Joined<["-"], "ffile-macro-prefix-to-remove=">,
+  Group<f_Group>, Flags<[DriverOption, CC1Option]>,
----------------
This opt name doesn’t match the command line option. 


================
Comment at: include/clang/Driver/Options.td:831
+  HelpText<"prefix to be removed from expanded string of __FILE__ macro">;
+def FILE_basename_only : Flag <["-"], "ffile-macro-basename-only">,
+  Group<f_Group>, Flags<[DriverOption, CC1Option]>,
----------------
Same here. 


================
Comment at: include/clang/Lex/PreprocessorOptions.h:122
+  /// matches the prefix of __FILE__, the matched part won't be expanded.
+  std::string __FILE__PrefixToRemove;
+
----------------
This identifier name is reserved for the implementation.


================
Comment at: include/clang/Lex/PreprocessorOptions.h:126
+  /// basename part of __FILE__ will be expanded.
+  bool __FILE__BasenameOnly;
+
----------------
Same here. 


================
Comment at: lib/Lex/PPMacroExpansion.cpp:1608
     if (PLoc.isValid()) {
-      FN += PLoc.getFilename();
+      StringRef Filename(PLoc.getFilename());
+      if (II == Ident__FILE__) {
----------------
Why not use =?


https://reviews.llvm.org/D17741





More information about the cfe-commits mailing list