[PATCH] D124420: [Serialization] Compress serialized macro expansion SLocEntries

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 01:20:46 PDT 2022


ilya-biryukov added inline comments.


================
Comment at: clang/lib/Serialization/ASTWriter.cpp:2181
+      // Common cases are covered by abbreviations.
+      unsigned Abbrev = [&]() -> unsigned {
+        if (!Expansion.isExpansionTokenRange()) // Token splits.
----------------
NIT: maybe avoid the lambda? The code is short enough to be readable without early returns:
```
unsigned Abbrev = 0;
if (Expansion.isExpansionTokenRange()) {
  if (Expansion.isMacroArgExpansion())
    Abbrev = SLocArgExpansionAbbrv;
  else if (EndIsRelative && Expansion.isFunctionMacroExpansion())
    Abbrev = SLocFunctionExpansionAbbrv;
  else if (EndIsRelative)
    Abbrev = SLocObjectExpansionAbbrv;
}
```


================
Comment at: clang/lib/Serialization/ASTWriter.cpp:2195
+      else
+        Stream.EmitRecord(SM_SLOC_EXPANSION_ENTRY,
+                          // To emit without abbrev, we must omit the code.
----------------
It's probably obvious, but I'm not an expert in bitcode format.

Can we have larger records now than before? Are any records emitted without abbreviations larger than with abbreviations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124420



More information about the cfe-commits mailing list