This will bring down the size from 40 bytes to 32 bytes.
Differential Revision: https://reviews.llvm.org/D153018
continue;
if (auto DefLoc = Macro->Info->getDefinitionLoc(); DefLoc.isValid())
Macros.push_back(
- {Tok.location(),
- include_cleaner::Macro{/*Name=*/PP.getIdentifierInfo(Tok.text(SM)),
+ {include_cleaner::Macro{/*Name=*/PP.getIdentifierInfo(Tok.text(SM)),
DefLoc},
- include_cleaner::RefType::Explicit});
+ Tok.location(), include_cleaner::RefType::Explicit});
}
return Macros;
}
/// Indicates that a piece of code refers to a symbol.
struct SymbolReference {
- /// The point in the code that refers to the symbol.
- SourceLocation RefLocation;
/// The symbol referred to.
Symbol Target;
+ /// The point in the code that refers to the symbol.
+ SourceLocation RefLocation;
/// Relation type between the reference location and the target.
RefType RT;
};
return;
// FIXME: Most of the work done here is repetitive. It might be useful to
// have a cache/batching.
- SymbolReference SymRef{Loc, ND, RT};
+ SymbolReference SymRef{ND, Loc, RT};
return CB(SymRef, headersForSymbol(ND, SM, PI));
});
}
walkAST(*Root, [&](SourceLocation Loc, const NamedDecl &D, RefType T) {
if(!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
return;
- R.addRef(SymbolReference{Loc, D, T});
+ R.addRef(SymbolReference{D, Loc, T});
});
for (const SymbolReference &Ref : MacroRefs) {
if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Ref.RefLocation)))
RefType RT = RefType::Explicit) {
if (MI.isBuiltinMacro())
return; // __FILE__ is not a reference.
- Recorded.MacroReferences.push_back(SymbolReference{
- Tok.getLocation(),
- Macro{Tok.getIdentifierInfo(), MI.getDefinitionLoc()}, RT});
+ Recorded.MacroReferences.push_back(
+ SymbolReference{Macro{Tok.getIdentifierInfo(), MI.getDefinitionLoc()},
+ Tok.getLocation(), RT});
}
bool Active = false;
Symbol Answer2 =
Macro{&Idents.get("ANSWER"), SM.getComposedLoc(HdrID, Hdr.point())};
EXPECT_THAT(
- offsetToProviders(AST, SM,
- {SymbolReference{SM.getComposedLoc(SM.getMainFileID(),
- Code.point("1")),
- Answer1, RefType::Explicit},
- SymbolReference{SM.getComposedLoc(SM.getMainFileID(),
- Code.point("2")),
- Answer2, RefType::Explicit}}),
+ offsetToProviders(
+ AST, SM,
+ {SymbolReference{
+ Answer1, SM.getComposedLoc(SM.getMainFileID(), Code.point("1")),
+ RefType::Explicit},
+ SymbolReference{
+ Answer2, SM.getComposedLoc(SM.getMainFileID(), Code.point("2")),
+ RefType::Explicit}}),
UnorderedElementsAre(
Pair(Code.point("1"), UnorderedElementsAre(HdrFile)),
Pair(Code.point("2"), UnorderedElementsAre(HdrFile)),