2013-04-15 22:50:35 +08:00
|
|
|
//===-- Core/IncludeExcludeInfo.h - IncludeExclude class def'n --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file provides the definition for the IncludeExcludeInfo class
|
|
|
|
/// to handle the include and exclude command line options.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-07-08 20:17:37 +08:00
|
|
|
|
2013-09-05 03:13:50 +08:00
|
|
|
#ifndef CLANG_MODERNIZE_INCLUDEEXCLUDEINFO_H
|
|
|
|
#define CLANG_MODERNIZE_INCLUDEEXCLUDEINFO_H
|
2013-04-15 22:50:35 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2013-05-03 03:02:02 +08:00
|
|
|
#include "llvm/Support/system_error.h"
|
2013-04-15 22:50:35 +08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/// \brief Class encapsulating the handling of include and exclude paths
|
|
|
|
/// provided by the user through command line options.
|
|
|
|
class IncludeExcludeInfo {
|
|
|
|
public:
|
2013-12-01 13:08:12 +08:00
|
|
|
/// \brief Read and parse a comma-separated lists of paths from
|
2013-05-03 03:02:02 +08:00
|
|
|
/// \a IncludeString and \a ExcludeString.
|
2013-04-15 22:50:35 +08:00
|
|
|
///
|
2013-05-03 03:02:02 +08:00
|
|
|
/// Returns error_code::success() on successful parse of the strings or
|
|
|
|
/// an error_code indicating the encountered error.
|
2014-06-12 21:32:11 +08:00
|
|
|
std::error_code readListFromString(llvm::StringRef IncludeString,
|
|
|
|
llvm::StringRef ExcludeString);
|
2013-04-15 22:50:35 +08:00
|
|
|
|
2013-05-03 03:02:02 +08:00
|
|
|
/// \brief Read and parse the lists of paths from \a IncludeListFile
|
|
|
|
/// and \a ExcludeListFile. Each file should contain one path per line.
|
|
|
|
///
|
|
|
|
/// Returns error_code::success() on successful read and parse of both files
|
|
|
|
/// or an error_code indicating the encountered error.
|
2014-06-12 21:32:11 +08:00
|
|
|
std::error_code readListFromFile(llvm::StringRef IncludeListFile,
|
|
|
|
llvm::StringRef ExcludeListFile);
|
2013-05-03 03:02:02 +08:00
|
|
|
|
|
|
|
/// \brief Determine if the given path is in the list of include paths but
|
2013-04-15 22:50:35 +08:00
|
|
|
/// not in the list of exclude paths.
|
2013-08-10 03:24:05 +08:00
|
|
|
///
|
|
|
|
/// \a FilePath shouldn't contain relative operators i.e. ".." or "." since
|
|
|
|
/// Path comes from the include/exclude list of paths in which relative
|
|
|
|
/// operators were removed.
|
2013-06-14 01:19:37 +08:00
|
|
|
bool isFileIncluded(llvm::StringRef FilePath) const;
|
2013-04-15 22:50:35 +08:00
|
|
|
|
2013-09-13 04:10:59 +08:00
|
|
|
/// \brief Determine if a file path was explicitly excluded.
|
|
|
|
bool isFileExplicitlyExcluded(llvm::StringRef FilePath) const;
|
|
|
|
|
|
|
|
/// \brief Determine if a list of include paths was provided.
|
|
|
|
bool isIncludeListEmpty() const { return IncludeList.empty(); }
|
|
|
|
|
2013-04-15 22:50:35 +08:00
|
|
|
private:
|
|
|
|
std::vector<std::string> IncludeList;
|
|
|
|
std::vector<std::string> ExcludeList;
|
|
|
|
};
|
|
|
|
|
2013-09-05 03:13:50 +08:00
|
|
|
#endif // CLANG_MODERNIZE_INCLUDEEXCLUDEINFO_H
|