-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lldb][ClangASTImporter][NFC] Emit a log message when we break MapImported invariant #112748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Michael137
merged 6 commits into
llvm:main
from
Michael137:lldb/warn-on-mapimported-conflict
Oct 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
247f263
[lldb][ClangASTImporter][NFC] Emit a log message when we break MapImp…
Michael137 c1e7815
fixup! add quotes
Michael137 b239e11
fixup! only do lookup when logging; add braces; WARNING->ERROR
Michael137 4069dbf
fixup! clang-format
Michael137 7262cbe
fixup! remove redundant local
Michael137 3bd2f8c
fixup! clang-format
Michael137 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1136,6 +1136,25 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) { | |
|
|
||
| void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo( | ||
| clang::Decl *to, clang::Decl *from) { | ||
| Log *log = GetLog(LLDBLog::Expressions); | ||
|
|
||
| auto getDeclName = [](Decl const *decl) { | ||
| std::string name_string; | ||
| if (auto const *from_named_decl = dyn_cast<clang::NamedDecl>(decl)) { | ||
| llvm::raw_string_ostream name_stream(name_string); | ||
| from_named_decl->printName(name_stream); | ||
| } | ||
|
|
||
| return name_string; | ||
| }; | ||
|
|
||
| if (auto *D = GetAlreadyImportedOrNull(from); D && D != to) | ||
| LLDB_LOG(log, | ||
| "[ClangASTImporter] WARNING: overwriting an already imported decl " | ||
| "'{0:x}' ('{1}') from '{2:x}' with '{3:x}'. Likely due to a name " | ||
| "conflict when importing '{1}'.", | ||
| D, getDeclName(from), from, to); | ||
|
|
||
| // We might have a forward declaration from a shared library that we | ||
| // gave external lexical storage so that Clang asks us about the full | ||
| // definition when it needs it. In this case the ASTImporter isn't aware | ||
|
|
@@ -1145,8 +1164,6 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo( | |
| // tell the ASTImporter that 'to' was imported from 'from'. | ||
| MapImported(from, to); | ||
|
|
||
| Log *log = GetLog(LLDBLog::Expressions); | ||
|
|
||
| if (llvm::Error err = ImportDefinition(from)) { | ||
| LLDB_LOG_ERROR(log, std::move(err), | ||
| "[ClangASTImporter] Error during importing definition: {0}"); | ||
|
|
@@ -1158,11 +1175,7 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo( | |
| to_tag->setCompleteDefinition(from_tag->isCompleteDefinition()); | ||
|
|
||
| if (Log *log_ast = GetLog(LLDBLog::AST)) { | ||
| std::string name_string; | ||
| if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) { | ||
| llvm::raw_string_ostream name_stream(name_string); | ||
| from_named_decl->printName(name_stream); | ||
| } | ||
| std::string name_string = getDeclName(from); | ||
|
||
| LLDB_LOG(log_ast, | ||
| "==== [ClangASTImporter][TUDecl: {0:x}] Imported " | ||
| "({1}Decl*){2:x}, named {3} (from " | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is expensive (I honestly don't know), you may want to put this in a
if(log)block.