Skip to content

The SourceLocation of the decl node related to macro extension is invalid. How to obtain the file and line number information according to the decl node? #122268

Open
@yaqianp

Description

@yaqianp

example:
Image

bool ClangASTVisitor::TraverseDecl(clang::Decl* decl)
{
    if (decl == nullptr) {
        return true;
    }
    if (auto* cxxRecordDecl = llvm::dyn_cast<clang::CXXRecordDecl>(decl);
        IsTemplateCXXRecordUninstantiated(cxxRecordDecl)) {
        return true;
    }
    const std::string& currFilename =
        m_astContext->getSourceManager().getFilename(decl->getEndLoc()).str();

    if (decl->getBeginLoc().isInvalid()) {
     // How to obtain the file and line number information according to the decl node?
   }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:as-a-librarylibclang and C++ APIquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions