This is an archive of the discontinued LLVM Phabricator instance.

[clang][analyzer] Own string keys in AnalyzerOptions::ConfigTable
AbandonedPublic

Authored by jansvoboda11 on Jan 28 2021, 9:23 AM.

Details

Summary

This patch replaces StringMap<...> with std::map<std::string, ...> in AnalyzerOptions::ConfigTable. It seems to be the only non-owning reference to command line arguments in the whole CompilerInvocation, which would introduce a lot of complexity with round-tripping arguments (D94472).

Diff Detail

Event Timeline

jansvoboda11 created this revision.Jan 28 2021, 9:23 AM
jansvoboda11 requested review of this revision.Jan 28 2021, 9:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2021, 9:23 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dexonsmith requested changes to this revision.Jan 28 2021, 12:12 PM

This patch replaces StringMap<...> with std::map<std::string, ...> in AnalyzerOptions::ConfigTable. It seems to be the only non-owning reference to command line arguments in the whole CompilerInvocation, which would introduce a lot of complexity with round-tripping arguments (D94472).

I think this patch can be skipped. StringMap owns its own strings. StringMapEntry uses tail allocation to include a null-terminated string inline. For details, have a look at StringMapEntry::Create in llvm/ADT/StringMapEntry.h.

This revision now requires changes to proceed.Jan 28 2021, 12:12 PM

I think this patch can be skipped. StringMap owns its own strings. StringMapEntry uses tail allocation to include a null-terminated string inline. For details, have a look at StringMapEntry::Create in llvm/ADT/StringMapEntry.h.

You're right.

I first discovered lifetime issues with Config when using a non-stable data structure for holding allocated strings. Reading the documentation and looking at the API of StringMap made me believe the keys are not owned and I forgot to double-check.

Closing this, as D95369 works correctly regardless.

jansvoboda11 abandoned this revision.Jan 29 2021, 12:56 AM