@@ -711,7 +711,7 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
711711class TranslateASTVisitor final
712712 : public RecursiveASTVisitor<TranslateASTVisitor> {
713713
714- struct MacroExpansionInfo {
714+ struct MacroDeclInfo {
715715 StringRef Name;
716716 };
717717
@@ -723,13 +723,13 @@ class TranslateASTVisitor final
723723 // Mapping from SourceManager FileID to index in files
724724 DenseMap<FileID, size_t > file_id_mapping;
725725 std::set<std::pair<void *, ASTEntryTag>> exportedTags;
726- std::unordered_map<MacroInfo*, MacroExpansionInfo > macros;
726+ std::unordered_map<MacroInfo*, MacroDeclInfo > macros;
727727
728728 // This stores a raw encoding of the macro call site SourceLocation, since
729729 // SourceLocation isn't hashable.
730730 std::unordered_set<unsigned > macroCallSites;
731- SmallVector<MacroInfo*, 1 > curMacroExpansionStack ;
732- StringRef curMacroExpansionSource ;
731+ SmallVector<MacroInfo*, 1 > curMacroInvocationStack ;
732+ StringRef curMacroInvocationSource ;
733733
734734 // Returns true when a new entry is added to exportedTags
735735 bool markForExport (void *ptr, ASTEntryTag tag) {
@@ -769,7 +769,7 @@ class TranslateASTVisitor final
769769 // Template required because Decl and Stmt don't share a common base class
770770 void encode_entry_raw (void *ast, ASTEntryTag tag, SourceRange loc,
771771 const QualType ty, bool rvalue,
772- bool isVaList, bool encodeMacroExpansions ,
772+ bool isVaList, bool encodeMacroInvocations ,
773773 const std::vector<void *> &childIds,
774774 std::function<void (CborEncoder *)> extra) {
775775 if (!markForExport (ast, tag))
@@ -808,21 +808,21 @@ class TranslateASTVisitor final
808808 // 9 - Is Rvalue (only for expressions)
809809 cbor_encode_boolean (&local, rvalue);
810810
811- // 10 - Macro expansion stack, starting with initial macro call and ending
811+ // 10 - Macro invocation stack, starting with initial macro call and ending
812812 // with the innermost replacement.
813813 cbor_encoder_create_array (&local, &childEnc,
814- encodeMacroExpansions ? curMacroExpansionStack .size () : 0 );
815- if (encodeMacroExpansions ) {
816- for (auto I = curMacroExpansionStack .rbegin (), E = curMacroExpansionStack .rend ();
814+ encodeMacroInvocations ? curMacroInvocationStack .size () : 0 );
815+ if (encodeMacroInvocations ) {
816+ for (auto I = curMacroInvocationStack .rbegin (), E = curMacroInvocationStack .rend ();
817817 I != E; ++I) {
818818 cbor_encode_uint (&childEnc, uintptr_t (*I));
819819 }
820820 }
821821 cbor_encoder_close_container (&local, &childEnc);
822822
823- // 11 - Macro expansion source string, if applicable.
824- if (!curMacroExpansionSource .empty ()) {
825- cbor_encode_string (&local, curMacroExpansionSource .str ());
823+ // 11 - Macro invocation source string, if applicable.
824+ if (!curMacroInvocationSource .empty ()) {
825+ cbor_encode_string (&local, curMacroInvocationSource .str ());
826826 } else {
827827 cbor_encode_null (&local);
828828 }
@@ -846,7 +846,7 @@ class TranslateASTVisitor final
846846 std::function<void (CborEncoder *)> extra = [](CborEncoder *) {}) {
847847 auto ty = ast->getType ();
848848 auto isVaList = false ;
849- auto encodeMacroExpansions = true ;
849+ auto encodeMacroInvocations = true ;
850850#if CLANG_VERSION_MAJOR < 13
851851 bool isRValue = ast->isRValue ();
852852#else
@@ -860,7 +860,7 @@ class TranslateASTVisitor final
860860 auto span = ast->getSourceRange ();
861861 expandSpanToFinalChar (span, Context);
862862 encode_entry_raw (ast, tag, span, ty, isRValue, isVaList,
863- encodeMacroExpansions , childIds, extra);
863+ encodeMacroInvocations , childIds, extra);
864864 typeEncoder.VisitQualTypeOf (ty, ast);
865865 }
866866
@@ -870,23 +870,23 @@ class TranslateASTVisitor final
870870 QualType s = QualType (static_cast <clang::Type *>(nullptr ), 0 );
871871 auto rvalue = false ;
872872 auto isVaList = false ;
873- auto encodeMacroExpansions = false ;
873+ auto encodeMacroInvocations = false ;
874874 auto span = ast->getSourceRange ();
875875 expandSpanToFinalChar (span, Context);
876876 encode_entry_raw (ast, tag, span, s, rvalue, isVaList,
877- encodeMacroExpansions , childIds, extra);
877+ encodeMacroInvocations , childIds, extra);
878878 }
879879
880880 void encode_entry (
881881 Decl *ast, ASTEntryTag tag, const std::vector<void *> &childIds,
882882 const QualType T,
883883 std::function<void (CborEncoder *)> extra = [](CborEncoder *) {}) {
884884 auto rvalue = false ;
885- auto encodeMacroExpansions = false ;
885+ auto encodeMacroInvocations = false ;
886886 auto span = ast->getSourceRange ();
887887 expandSpanToFinalChar (span, Context);
888888 encode_entry_raw (ast, tag, span, T, rvalue,
889- isVaList (ast, T), encodeMacroExpansions , childIds, extra);
889+ isVaList (ast, T), encodeMacroInvocations , childIds, extra);
890890 }
891891
892892 // / Explicitly override the source location of this decl for cases where the
@@ -897,10 +897,10 @@ class TranslateASTVisitor final
897897 const std::vector<void *> &childIds, const QualType T,
898898 std::function<void (CborEncoder *)> extra = [](CborEncoder *) {}) {
899899 auto rvalue = false ;
900- auto encodeMacroExpansions = false ;
900+ auto encodeMacroInvocations = false ;
901901 expandSpanToFinalChar (loc, Context);
902902 encode_entry_raw (ast, tag, loc, T, rvalue,
903- isVaList (ast, T), encodeMacroExpansions , childIds, extra);
903+ isVaList (ast, T), encodeMacroInvocations , childIds, extra);
904904 }
905905
906906 bool VisitMacro (StringRef name, SourceLocation loc, MacroInfo *mac, Expr *E) {
@@ -973,11 +973,11 @@ class TranslateASTVisitor final
973973
974974 void encodeMacros () {
975975 // Sort macros by source location
976- std::vector<std::pair<MacroInfo *, MacroExpansionInfo >> macro_vec (
976+ std::vector<std::pair<MacroInfo *, MacroDeclInfo >> macro_vec (
977977 macros.begin (), macros.end ());
978978 std::sort (macro_vec.begin (), macro_vec.end (),
979- [](const std::pair<MacroInfo *, MacroExpansionInfo > &a,
980- const std::pair<MacroInfo *, MacroExpansionInfo > &b) {
979+ [](const std::pair<MacroInfo *, MacroDeclInfo > &a,
980+ const std::pair<MacroInfo *, MacroDeclInfo > &b) {
981981 return a.first ->getDefinitionLoc () <
982982 b.first ->getDefinitionLoc ();
983983 });
@@ -1369,8 +1369,8 @@ class TranslateASTVisitor final
13691369 //
13701370
13711371 bool VisitExpr (Expr *E) {
1372- curMacroExpansionStack .clear ();
1373- curMacroExpansionSource = StringRef ();
1372+ curMacroInvocationStack .clear ();
1373+ curMacroInvocationSource = StringRef ();
13741374
13751375 // We only translate constant macro objects to Rust consts, so this
13761376 // expression must be constant.
@@ -1396,7 +1396,7 @@ class TranslateASTVisitor final
13961396 return true ;
13971397 }
13981398
1399- curMacroExpansionSource =
1399+ curMacroInvocationSource =
14001400 Lexer::getSourceText (ExpansionStack[0 ].range , Mgr, Context->getLangOpts ());
14011401
14021402 for (auto &elem : ExpansionStack) {
@@ -1418,7 +1418,7 @@ class TranslateASTVisitor final
14181418 }
14191419
14201420 if (VisitMacro (IdentifierInfo->getName (), loc, MacroInfo, E)) {
1421- curMacroExpansionStack .push_back (MacroInfo);
1421+ curMacroInvocationStack .push_back (MacroInfo);
14221422 }
14231423 }
14241424
0 commit comments