Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:22

0001 //===--- FileExtensionsUtils.h - clang-tidy --------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
0011 
0012 #include "../FileExtensionsSet.h"
0013 #include "clang/Basic/SourceLocation.h"
0014 #include "clang/Basic/SourceManager.h"
0015 #include "llvm/ADT/SmallSet.h"
0016 #include "llvm/ADT/StringRef.h"
0017 #include <optional>
0018 
0019 namespace clang::tidy::utils {
0020 
0021 /// Checks whether expansion location of \p Loc is in header file.
0022 bool isExpansionLocInHeaderFile(SourceLocation Loc, const SourceManager &SM,
0023                                 const FileExtensionsSet &HeaderFileExtensions);
0024 
0025 /// Checks whether presumed location of \p Loc is in header file.
0026 bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM,
0027                                const FileExtensionsSet &HeaderFileExtensions);
0028 
0029 /// Checks whether spelling location of \p Loc is in header file.
0030 bool isSpellingLocInHeaderFile(SourceLocation Loc, SourceManager &SM,
0031                                const FileExtensionsSet &HeaderFileExtensions);
0032 
0033 /// Returns recommended default value for the list of header file
0034 /// extensions.
0035 inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
0036 
0037 /// Returns recommended default value for the list of implementation file
0038 /// extensions.
0039 inline StringRef defaultImplementationFileExtensions() {
0040   return "c;cc;cpp;cxx";
0041 }
0042 
0043 /// Returns recommended default value for the list of file extension
0044 /// delimiters.
0045 inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
0046 
0047 /// Parses header file extensions from a semicolon-separated list.
0048 bool parseFileExtensions(StringRef AllFileExtensions,
0049                          FileExtensionsSet &FileExtensions,
0050                          StringRef Delimiters);
0051 
0052 /// Decides whether a file has a header file extension.
0053 /// Returns the file extension, if included in the provided set.
0054 std::optional<StringRef>
0055 getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions);
0056 
0057 /// Decides whether a file has one of the specified file extensions.
0058 bool isFileExtension(StringRef FileName,
0059                      const FileExtensionsSet &FileExtensions);
0060 
0061 } // namespace clang::tidy::utils
0062 
0063 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H