本文整理汇总了C++中Analyser::toplevel方法的典型用法代码示例。如果您正苦于以下问题:C++ Analyser::toplevel方法的具体用法?C++ Analyser::toplevel怎么用?C++ Analyser::toplevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyser
的用法示例。
在下文中一共展示了Analyser::toplevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: include_file
static void include_file(Analyser& analyser,
SourceLocation where,
bool,
std::string const& name)
{
data& status(analyser.attachment<data>());
if (status.check_)
{
if (analyser.is_component_header(name) ||
analyser.is_component_header(analyser.toplevel()))
{
status.header_seen_ = true;
}
else if (!status.header_seen_
&& analyser.toplevel() != name
&& builtin != name
&& command_line != name
&& "bdes_ident.h" != name
&& !analyser.is_main())
{
analyser.report(where, check_name, "TR09",
"Include files precede component header",
true);
status.check_ = false;
}
}
}
示例2: open_file
static void open_file(Analyser& analyser,
SourceLocation where,
const std::string&,
const std::string& name)
{
FileName fn(name);
std::string filename = fn.name();
if (analyser.is_component_header(filename) ||
name == analyser.toplevel()) {
const SourceManager &m = analyser.manager();
llvm::StringRef buf = m.getBuffer(m.getFileID(where))->getBuffer();
if (buf.size() == 0) {
return;
}
buf = buf.substr(0, buf.find('\n')).rtrim();
std::string expectcpp("// " + filename);
expectcpp.resize(70, ' ');
expectcpp += "-*-C++-*-";
std::string expectc("/* " + filename);
expectc.resize(69, ' ');
expectc += "-*-C-*- */";
if ( !buf.equals(expectcpp)
&& !buf.equals(expectc)
&& buf.find("GENERATED") == buf.npos) {
std::pair<size_t, size_t> mcpp = mid_mismatch(buf, expectcpp);
std::pair<size_t, size_t> mc = mid_mismatch(buf, expectc);
std::pair<size_t, size_t> m;
std::string expect;
if (mcpp.first >= mc.first || mcpp.second >= mc.second) {
m = mcpp;
expect = expectcpp;
} else {
m = mc;
expect = expectc;
}
analyser.report(where.getLocWithOffset(m.first),
check_name, "HL01",
"File headline incorrect", true);
analyser.report(where.getLocWithOffset(m.first),
check_name, "HL01",
"Correct format is\n%0",
true, DiagnosticIDs::Note)
<< expect;
if (m.first == 0) {
analyser.InsertTextAfter(
where.getLocWithOffset(m.first), expect + "\n");
} else {
analyser.ReplaceText(analyser.get_line_range(where), expect);
}
}
}
}
示例3: declaration
static void declaration(Analyser& analyser, Decl const* decl)
{
data& status(analyser.attachment<data>());
if (status.check_)
{
if (!status.header_seen_ ||
analyser.is_component_header(analyser.toplevel()))
{
status.header_seen_ = true;
status.line_ = 0;
}
Location loc(analyser.get_location(decl));
if ((analyser.toplevel() != loc.file() && status.header_seen_)
|| (analyser.toplevel() == loc.file()
&& status.line_ < loc.line()))
{
status.check_ = false;
}
else if (((analyser.toplevel() != loc.file() && !status.header_seen_)
|| loc.line() < status.line_)
&& builtin != loc.file() && command_line != loc.file()
&& (llvm::dyn_cast<NamedDecl>(decl) == 0
|| utils::end(id_names)
== std::find(utils::begin(id_names),
utils::end(id_names),
llvm::dyn_cast<NamedDecl>(decl)
->getNameAsString()))
&& !analyser.is_main())
{
analyser.report(decl, check_name, "TR09",
"Declarations precede component header",
true);
status.check_ = false;
}
}
}