[clang] [clang] Introduce "binary" StringLiteral for #embed data (PR #127629)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 06:40:39 PDT 2025


================
@@ -1332,6 +1334,11 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
                                  const LangOptions &Features,
                                  const TargetInfo &Target, unsigned *StartToken,
                                  unsigned *StartTokenByteOffset) const {
+  // No source location of bytes for binary literals since they don't come from
+  // source.
+  if (getKind() == StringLiteralKind::Binary)
+    return getStrTokenLoc(0);
----------------
Fznamznon wrote:

It will point at the beginning of the StringLiteral, but not to a particular problematic byte (which this function intends to find). In case of `#embed` it will point to the directive location. The test I'm adding should exercise that.

https://github.com/llvm/llvm-project/pull/127629


More information about the cfe-commits mailing list