[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments={32,64}: widen integer arguments to int64 in unprototyped function calls

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 12 11:57:40 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/LangOptions.h:262-264
+    /// Unprototyped integer arguments are extended to 32 bits.
+    ExtendTo32,
+    /// Unprototyped integer arguments are extended to 64 bits.
----------------
The comments aren't quite right as this matters in functions with prototypes as well (due to variadic arguments). How about "integer arguments are sign or zero extended to 32/64 bits during default argument promotions."?


================
Comment at: clang/include/clang/Basic/TargetInfo.h:1415
 
+  virtual bool supportsExtendIntArgs() const { return false; }
+
----------------
This should get a comment explaining what it does. The name is a bit generic too (esp given that there's an `_ExtInt` type that sounds like an "extended int").

Is there anything truly target-specific about the functionality? It seems like this behavior would be plausibly useful regardless of target architecture. 


================
Comment at: clang/include/clang/Driver/Options.td:1432-1433
+  Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Controls how scalar integer arguments are extended in calls"
+           " to unprototyped and varargs functions">,
+  Values<"32,64">,
----------------
It's a bit more conventional to use a trailing whitespace in adjacent string literals.


================
Comment at: clang/test/CodeGen/extend-arg-64.c:19
+
+int vararg(int, ...);
+
----------------
Can you also add a test for K&R C functions? e.g., `int knr();` `sum = knr(sum, u32, s32, u16, s16, u8, s8);`

Also, can you show what happens when passing a `long long` and an `_ExtInt`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101640/new/

https://reviews.llvm.org/D101640



More information about the cfe-commits mailing list