Add consistent logging for dynamic mappings
* Do all this logging on level 8, whether logging is on for file or not * Always say "Add dynamic mappings..." * Don't log quoted from->to, that's already logged in AddMapping * State the reason dynamic mapping is added * Include file paths where available This should make it easier to troubleshoot strange effects from dynamic mappings triggered by IWYU itself.
This commit is contained in:
parent
68646a5efd
commit
6d5414fcf3
|
@ -1306,6 +1306,7 @@ void IncludePicker::AddDirectInclude(const string& includer_filepath,
|
|||
// the closing quote as part of the .*.
|
||||
AddFriendRegex(includee_filepath,
|
||||
quoted_includee.substr(0, internal_pos) + ".*");
|
||||
VERRS(8) << "Adding dynamic mapping for internal/ header\n";
|
||||
AddMapping(quoted_includee, mapped_includer);
|
||||
}
|
||||
|
||||
|
@ -1315,6 +1316,7 @@ void IncludePicker::AddDirectInclude(const string& includer_filepath,
|
|||
string public_header = quoted_includee;
|
||||
StripPast(&public_header, "/"); // read past "asm-whatever/"
|
||||
public_header = "<asm/" + public_header; // now it's <asm/something.h>
|
||||
VERRS(8) << "Adding dynamic mapping for <asm-*> header\n";
|
||||
AddMapping(quoted_includee, MappedInclude(public_header));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2124,6 +2124,9 @@ void IwyuFileInfo::HandlePreprocessingDone() {
|
|||
ERRSYM(file_) << "Mark " << quoted_file_
|
||||
<< " as public header for " << private_include
|
||||
<< " because used macro is defined by includer.\n";
|
||||
VERRS(8) << "Adding dynamic mapping for reverse macro dependency: "
|
||||
<< "(" << GetFilePath(macro_use_includee) << ") -> ("
|
||||
<< GetFilePath(file_) << ")\n";
|
||||
MutableGlobalIncludePicker()->AddMapping(
|
||||
private_include, MappedInclude(quoted_file_, GetFilePath(file_)));
|
||||
MutableGlobalIncludePicker()->MarkIncludeAsPrivate(private_include);
|
||||
|
|
|
@ -263,12 +263,11 @@ void IwyuPreprocessorInfo::HandlePragmaComment(SourceRange comment_range) {
|
|||
|
||||
const string quoted_this_file
|
||||
= ConvertToQuotedInclude(GetFilePath(begin_loc));
|
||||
|
||||
VERRS(8) << "Adding dynamic mapping for private pragma\n";
|
||||
MutableGlobalIncludePicker()->AddMapping(quoted_this_file,
|
||||
MappedInclude(suggested));
|
||||
MutableGlobalIncludePicker()->MarkIncludeAsPrivate(quoted_this_file);
|
||||
ERRSYM(this_file_entry) << "Adding private pragma-mapping: "
|
||||
<< quoted_this_file << " -> "
|
||||
<< suggested << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -377,13 +376,12 @@ void IwyuPreprocessorInfo::ProcessHeadernameDirectivesInFile(
|
|||
for (string& public_include : public_includes) {
|
||||
StripWhiteSpace(&public_include);
|
||||
const string quoted_header_name = "<" + public_include + ">";
|
||||
|
||||
VERRS(8) << "Adding dynamic mapping for @headername\n";
|
||||
MutableGlobalIncludePicker()->AddMapping(
|
||||
quoted_private_include, MappedInclude(quoted_header_name));
|
||||
MutableGlobalIncludePicker()->MarkIncludeAsPrivate(
|
||||
quoted_private_include);
|
||||
ERRSYM(GetFileEntry(current_loc)) << "Adding @headername mapping: "
|
||||
<< quoted_private_include << "->"
|
||||
<< quoted_header_name << "\n";
|
||||
}
|
||||
break; // No more than one @headername directive allowed.
|
||||
}
|
||||
|
@ -447,19 +445,19 @@ void IwyuPreprocessorInfo::MaybeProtectInclude(
|
|||
const string includer_path = GetFilePath(includer);
|
||||
const string quoted_includer = ConvertToQuotedInclude(includer_path);
|
||||
MappedInclude map_to(quoted_includer, includer_path);
|
||||
VERRS(8) << "Adding dynamic mapping for export pragma: "
|
||||
<< "(" << GetFilePath(includee) << ") -> (" << includer_path
|
||||
<< ")\n";
|
||||
MutableGlobalIncludePicker()->AddMapping(include_name_as_written, map_to);
|
||||
ERRSYM(includer) << "Adding pragma-export mapping: "
|
||||
<< include_name_as_written << " -> "
|
||||
<< map_to.quoted_include << "\n";
|
||||
// Relative includes can be problematic as map keys, because they are
|
||||
// context-dependent. Convert it to a context-free quoted include
|
||||
// (which may contain the full path to the file), and add that too.
|
||||
string map_from = ConvertToQuotedInclude(GetFilePath(includee));
|
||||
if (map_from != include_name_as_written) {
|
||||
VERRS(8) << "Adding dynamic mapping for export pragma (relative): "
|
||||
<< "(" << GetFilePath(includee) << ") -> (" << includer_path
|
||||
<< ")\n";
|
||||
MutableGlobalIncludePicker()->AddMapping(map_from, map_to);
|
||||
ERRSYM(includer) << "Adding pragma-export mapping: "
|
||||
<< map_from << " -> " << map_to.quoted_include
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
// We also always keep #includes of .c files: iwyu doesn't touch those.
|
||||
|
|
Loading…
Reference in New Issue