summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBolshakov <bolsh.andrey@yandex.ru>2023-04-08 18:46:17 +0300
committerKim Gräsman <kim.grasman@gmail.com>2023-04-16 08:17:15 +0200
commit44832a913f6565fa347a0cf0787badcf52dbf5a8 (patch)
tree317396c84fbd6ff99640ea8645ca2727dbe624e9
parent5540ff09d853605abd328121381a9b720e4269cd (diff)
Provide default values for class members
Otherwise, one could get an undefined behavior when forgetting to set them in a constructor. No functional change.
-rw-r--r--iwyu_output.cc13
-rw-r--r--iwyu_output.h16
2 files changed, 10 insertions, 19 deletions
diff --git a/iwyu_output.cc b/iwyu_output.cc
index d9d7e3b..1834618 100644
--- a/iwyu_output.cc
+++ b/iwyu_output.cc
@@ -492,13 +492,7 @@ string MungedForwardDeclareLine(const NamedDecl* decl) {
OneIncludeOrForwardDeclareLine::OneIncludeOrForwardDeclareLine(
const NamedDecl* fwd_decl)
- : line_(internal::MungedForwardDeclareLine(fwd_decl)),
- start_linenum_(-1), // set 'for real' below
- end_linenum_(-1), // set 'for real' below
- is_desired_(false),
- is_present_(false),
- included_file_(nullptr),
- fwd_decl_(fwd_decl) {
+ : line_(internal::MungedForwardDeclareLine(fwd_decl)), fwd_decl_(fwd_decl) {
const SourceRange decl_lines = GetSourceRangeOfClassDecl(fwd_decl);
// We always want to use the instantiation line numbers: for code like
// FORWARD_DECLARE_CLASS(MyClass);
@@ -512,11 +506,8 @@ OneIncludeOrForwardDeclareLine::OneIncludeOrForwardDeclareLine(
: line_("#include " + quoted_include),
start_linenum_(linenum),
end_linenum_(linenum),
- is_desired_(false),
- is_present_(false),
quoted_include_(quoted_include),
- included_file_(included_file),
- fwd_decl_(nullptr) {
+ included_file_(included_file) {
}
bool OneIncludeOrForwardDeclareLine::HasSymbolUse(const string& symbol_name)
diff --git a/iwyu_output.h b/iwyu_output.h
index 9375ea1..a0f09cc 100644
--- a/iwyu_output.h
+++ b/iwyu_output.h
@@ -203,17 +203,17 @@ class OneIncludeOrForwardDeclareLine {
}
private:
- string line_; // '#include XXX' or 'class YYY;'
- int start_linenum_;
- int end_linenum_;
- bool is_desired_; // IWYU will recommend this line
- bool is_present_; // line was present before the IWYU run
+ string line_; // '#include XXX' or 'class YYY;'
+ int start_linenum_ = -1;
+ int end_linenum_ = -1;
+ bool is_desired_ = false; // IWYU will recommend this line
+ bool is_present_ = false; // line was present before the IWYU run
map<string, int> symbol_counts_; // how many times we referenced each symbol
// Only either two following members are set for includes
- string quoted_include_; // quoted file name we're including
- const clang::FileEntry* included_file_; // the file we're including
+ string quoted_include_; // quoted file name we're including
+ const clang::FileEntry* included_file_ = nullptr; // the file we're including
// ...or this member is set for the fwd-decl we're emitting.
- const clang::NamedDecl* fwd_decl_;
+ const clang::NamedDecl* fwd_decl_ = nullptr;
};
// This class holds IWYU information about a single file (FileEntry)