MCPcopy Create free account
hub / github.com/KDAB/codebrowser / MacroUndefined

Method MacroUndefined

generator/preprocessorcallback.cpp:191–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void PreprocessorCallback::MacroUndefined(const clang::Token& MacroNameTok, PreprocessorCallback::MyMacroDefinition MD
192#if CLANG_VERSION_MAJOR >= 5
193 , const clang::MacroDirective *
194#endif
195 )
196{
197 clang::SourceLocation loc = MacroNameTok.getLocation();
198 if (!loc.isValid() || !loc.isFileID())
199 return;
200
201 clang::SourceManager &sm = annotator.getSourceMgr();
202 clang::FileID FID = sm.getFileID(loc);
203 if (!annotator.shouldProcess(FID))
204 return;
205
206 std::string ref = llvm::Twine("_M/", MacroNameTok.getIdentifierInfo()->getName()).str();
207 std::string link;
208 std::string dataProj;
209 clang::SourceLocation defLoc;
210 clang::FileID defFID;
211
212 if (MD) {
213#if CLANG_VERSION_MAJOR != 3 || CLANG_VERSION_MINOR >= 7
214 auto *MI = MD.getMacroInfo();
215#else
216 auto *MI = MD->getMacroInfo();
217#endif
218 if (MI) {
219 defLoc = MI->getDefinitionLoc();
220 defFID = sm.getFileID(defLoc);
221 }
222 }
223
224 if (defFID.isInvalid() || defFID != FID) {
225 if (!defFID.isInvalid()) {
226 link = annotator.pathTo(FID, defFID, &dataProj);
227 }
228 if (link.empty()) {
229 std::string tag = "class=\"macro\" data-ref=\"" % ref % "\"";
230 annotator.generator(FID).addTag("span", tag, sm.getFileOffset(loc), MacroNameTok.getLength());
231 return;
232 }
233
234 if (!dataProj.empty()) {
235 dataProj = " data-proj=\"" % dataProj % "\"";
236 }
237 }
238
239 if (sm.getMainFileID() != defFID) {
240 annotator.registerMacro(ref, MacroNameTok.getLocation(), Annotator::Use_Write);
241 }
242
243 std::string tag = "class=\"macro\" href=\"" % link % "#" % llvm::Twine(sm.getExpansionLineNumber(defLoc)).str()
244 % "\" data-ref=\"" % ref % "\"" % dataProj;
245 annotator.generator(FID).addTag("a", tag, sm.getFileOffset(loc), MacroNameTok.getLength());
246}
247
248bool PreprocessorCallback::FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl<char> &RecoveryPath)

Callers

nothing calls this directly

Calls 5

TwineClass · 0.85
pathToMethod · 0.80
addTagMethod · 0.80
registerMacroMethod · 0.80
shouldProcessMethod · 0.45

Tested by

no test coverage detected