| 291 | } |
| 292 | |
| 293 | void PreprocessorCallback::Defined(const clang::Token& MacroNameTok, MyMacroDefinition MD, |
| 294 | clang::SourceRange Range) |
| 295 | { |
| 296 | clang::SourceLocation loc = MacroNameTok.getLocation(); |
| 297 | if (!loc.isValid() || !loc.isFileID()) |
| 298 | return; |
| 299 | |
| 300 | clang::SourceManager &sm = annotator.getSourceMgr(); |
| 301 | |
| 302 | clang::FileID FID = sm.getFileID(loc); |
| 303 | if (!annotator.shouldProcess(FID)) |
| 304 | return; |
| 305 | |
| 306 | std::string ref = llvm::Twine("_M/", MacroNameTok.getIdentifierInfo()->getName()).str(); |
| 307 | std::string link; |
| 308 | std::string dataProj; |
| 309 | clang::SourceLocation defLoc; |
| 310 | clang::FileID defFID; |
| 311 | |
| 312 | if (MD) { |
| 313 | #if CLANG_VERSION_MAJOR != 3 || CLANG_VERSION_MINOR >= 7 |
| 314 | auto *MI = MD.getMacroInfo(); |
| 315 | #else |
| 316 | auto *MI = MD->getMacroInfo(); |
| 317 | #endif |
| 318 | if (MI) { |
| 319 | defLoc = MI->getDefinitionLoc(); |
| 320 | defFID = sm.getFileID(defLoc); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | if (defFID.isInvalid() || defFID != FID) { |
| 325 | if (!defFID.isInvalid()) { |
| 326 | link = annotator.pathTo(FID, defFID, &dataProj); |
| 327 | } |
| 328 | if (link.empty()) { |
| 329 | std::string tag = "class=\"macro\" data-ref=\"" % ref % "\""; |
| 330 | annotator.generator(FID).addTag("span", tag, sm.getFileOffset(loc), MacroNameTok.getLength()); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | if (!dataProj.empty()) { |
| 335 | dataProj = " data-proj=\"" % dataProj % "\""; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | if (sm.getMainFileID() != defFID) { |
| 340 | annotator.registerMacro(ref, MacroNameTok.getLocation(), Annotator::Use_Address); |
| 341 | } |
| 342 | |
| 343 | std::string tag = "class=\"macro\" href=\"" % link % "#" % llvm::Twine(sm.getExpansionLineNumber(defLoc)).str() |
| 344 | % "\" data-ref=\"" % ref % "\"" % dataProj; |
| 345 | annotator.generator(FID).addTag("a", tag, sm.getFileOffset(loc), MacroNameTok.getLength()); |
| 346 | } |
| 347 | |
| 348 | void PreprocessorCallback::HandlePPCond(clang::SourceLocation Loc, clang::SourceLocation IfLoc) |
| 349 | { |
nothing calls this directly
no test coverage detected