MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / openHeader

Function openHeader

externals/simplecpp/simplecpp.cpp:3071–3091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3069}
3070
3071static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader)
3072{
3073 if (simplecpp::isAbsolutePath(header))
3074 return openHeaderDirect(f, simplecpp::simplifyPath(header));
3075
3076 // prefer first to search the header relatively to source file if found, when not a system header
3077 if (!systemheader) {
3078 std::string path = openHeaderDirect(f, simplecpp::simplifyPath(dirPath(sourcefile) + header));
3079 if (!path.empty()) {
3080 return path;
3081 }
3082 }
3083
3084 // search the header on the include paths (provided by the flags "-I...")
3085 for (const auto &includePath : dui.includePaths) {
3086 std::string path = openHeaderDirect(f, simplecpp::simplifyPath(includePath + "/" + header));
3087 if (!path.empty())
3088 return path;
3089 }
3090 return "";
3091}
3092
3093std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDataCache::name_map_type::iterator &name_it, const simplecpp::DUI &dui, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
3094{

Callers 2

simplifyHasIncludeFunction · 0.85
preprocessMethod · 0.85

Calls 5

isAbsolutePathFunction · 0.85
openHeaderDirectFunction · 0.85
simplifyPathFunction · 0.85
dirPathFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected