[PATCH] D158933: [clang] Implement -funsigned-bitfields

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 29 01:22:52 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:18137
+
+      // TODO: Somehow get the explicit signdness info, maybe with the usage of
+      // the typedef's name (Typedef->getDecl()->getNameAsString()), look it up
----------------
The information seems preserved in `BuiltinTypeLoc::getWrittenSignSpec`
>From `TypedefType::getDecl`, you can get a `TypedefNameDecl`, which has a `getTypeSourceInfo`, which gets you a `TypeSourceInfo`, that you can extract a `TypeLoc` from, and if you cast that to `BuiltinTypeLoc`, you might be able to find what you need. Good luck!


================
Comment at: clang/lib/Sema/SemaDecl.cpp:18146-18158
+      // Change to unsigned variant
+      if (ResultType == Context.CharTy)
+        ResultType = Context.UnsignedCharTy;
+      else if (ResultType == Context.ShortTy)
+        ResultType = Context.UnsignedShortTy;
+      else if (ResultType == Context.IntTy)
+        ResultType = Context.UnsignedIntTy;
----------------
`ASTContext::getCorrespondingUnsignedType` is probably the better way to do that


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

https://reviews.llvm.org/D158933



More information about the cfe-commits mailing list