Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/clang-tidy/utils/ASTUtils.h b/linux-x64/clang/include/clang-tidy/utils/ASTUtils.h
new file mode 100644
index 0000000..ad2a055
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/ASTUtils.h
@@ -0,0 +1,45 @@
+//===---------- ASTUtils.h - clang-tidy -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
+
+#include "clang/AST/AST.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+// Returns the (closest) Function declaration surrounding |Statement| or NULL.
+const FunctionDecl *getSurroundingFunction(ASTContext &Context,
+ const Stmt &Statement);
+// Determine whether Expr is a Binary or Ternary expression.
+bool IsBinaryOrTernary(const Expr *E);
+
+/// Checks whether a macro flag is present in the given argument. Only considers
+/// cases of single match or match in a binary OR expression. For example,
+/// <needed-flag> or <flag> | <needed-flag> | ...
+bool exprHasBitFlagWithSpelling(const Expr *Flags, const SourceManager &SM,
+ const LangOptions &LangOpts,
+ StringRef FlagName);
+
+// Check if the range is entirely contained within a macro argument.
+bool rangeIsEntirelyWithinMacroArgument(SourceRange Range,
+ const SourceManager *SM);
+
+// Check if the range contains any locations from a macro expansion.
+bool rangeContainsMacroExpansion(SourceRange Range, const SourceManager *SM);
+
+// Can a fix-it be issued for this whole Range?
+// FIXME: false-negative if the entire range is fully expanded from a macro.
+bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM);
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/Aliasing.h b/linux-x64/clang/include/clang-tidy/utils/Aliasing.h
new file mode 100644
index 0000000..e43995a
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/Aliasing.h
@@ -0,0 +1,36 @@
+//===------------- Aliasing.h - clang-tidy --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ALIASING_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ALIASING_H
+
+#include "clang/AST/Decl.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// Returns whether \p Var has a pointer or reference in \p Func.
+///
+/// Example:
+/// void f() {
+/// int n;
+/// ...
+/// int *p = &n;
+/// }
+///
+/// For `f()` and `n` the function returns ``true`` because `p` is a
+/// pointer to `n` created in `f()`.
+
+bool hasPtrOrReferenceInFunc(const FunctionDecl *Func, const VarDecl *Var);
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_ALIASING_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/DeclRefExprUtils.h b/linux-x64/clang/include/clang-tidy/utils/DeclRefExprUtils.h
new file mode 100644
index 0000000..abf3529
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/DeclRefExprUtils.h
@@ -0,0 +1,59 @@
+//===--- DeclRefExprUtils.h - clang-tidy-------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace decl_ref_expr {
+
+/// Returns true if all ``DeclRefExpr`` to the variable within ``Stmt``
+/// do not modify it.
+///
+/// Returns ``true`` if only const methods or operators are called on the
+/// variable or the variable is a const reference or value argument to a
+/// ``callExpr()``.
+bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
+ ASTContext &Context);
+
+/// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt``.
+llvm::SmallPtrSet<const DeclRefExpr *, 16>
+allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context);
+
+/// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Decl``.
+llvm::SmallPtrSet<const DeclRefExpr *, 16>
+allDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context);
+
+/// Returns set of all ``DeclRefExprs`` to ``VarDecl`` within ``Stmt`` where
+/// ``VarDecl`` is guaranteed to be accessed in a const fashion.
+llvm::SmallPtrSet<const DeclRefExpr *, 16>
+constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
+ ASTContext &Context);
+
+/// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-constructor
+/// call expression within ``Decl``.
+bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
+ ASTContext &Context);
+
+/// Returns ``true`` if ``DeclRefExpr`` is the argument of a copy-assignment
+/// operator CallExpr within ``Decl``.
+bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
+ ASTContext &Context);
+
+} // namespace decl_ref_expr
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_DECLREFEXPRUTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/ExceptionAnalyzer.h b/linux-x64/clang/include/clang-tidy/utils/ExceptionAnalyzer.h
new file mode 100644
index 0000000..2ae08c8
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/ExceptionAnalyzer.h
@@ -0,0 +1,156 @@
+//===--- ExceptionAnalyzer.h - clang-tidy -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
+class ExceptionAnalyzer {
+public:
+ enum class State : std::int8_t {
+ Throwing = 0, ///< The function can definitely throw given an AST.
+ NotThrowing = 1, ///< This function can not throw, given an AST.
+ Unknown = 2, ///< This can happen for extern functions without available
+ ///< definition.
+ };
+
+ /// Bundle the gathered information about an entity like a function regarding
+ /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+ /// neutral element in terms of information propagation.
+ /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+ /// does not include *ALL* possible types as there is the possibility that
+ /// an 'Unknown' function is called that might throw a previously unknown
+ /// exception at runtime.
+ class ExceptionInfo {
+ public:
+ using Throwables = llvm::SmallSet<const Type *, 2>;
+ static ExceptionInfo createUnknown() {
+ return ExceptionInfo(State::Unknown);
+ }
+ static ExceptionInfo createNonThrowing() {
+ return ExceptionInfo(State::Throwing);
+ }
+
+ /// By default the exception situation is unknown and must be
+ /// clarified step-wise.
+ ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ ExceptionInfo(State S)
+ : Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ ExceptionInfo(const ExceptionInfo &) = default;
+ ExceptionInfo &operator=(const ExceptionInfo &) = default;
+ ExceptionInfo(ExceptionInfo &&) = default;
+ ExceptionInfo &operator=(ExceptionInfo &&) = default;
+
+ State getBehaviour() const { return Behaviour; }
+
+ /// Register a single exception type as recognized potential exception to be
+ /// thrown.
+ void registerException(const Type *ExceptionType);
+
+ /// Registers a `SmallVector` of exception types as recognized potential
+ /// exceptions to be thrown.
+ void registerExceptions(const Throwables &Exceptions);
+
+ /// Updates the local state according to the other state. That means if
+ /// for example a function contains multiple statements the 'ExceptionInfo'
+ /// for the final function is the merged result of each statement.
+ /// If one of these statements throws the whole function throws and if one
+ /// part is unknown and the rest is non-throwing the result will be
+ /// unknown.
+ ExceptionInfo &merge(const ExceptionInfo &Other);
+
+ /// This method is useful in case 'catch' clauses are analyzed as it is
+ /// possible to catch multiple exception types by one 'catch' if they
+ /// are a subclass of the 'catch'ed exception type.
+ /// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+ bool filterByCatch(const Type *BaseClass);
+
+ /// Filter the set of thrown exception type against a set of ignored
+ /// types that shall not be considered in the exception analysis.
+ /// This includes explicit `std::bad_alloc` ignoring as separate option.
+ ExceptionInfo &
+ filterIgnoredExceptions(const llvm::StringSet<> &IgnoredTypes,
+ bool IgnoreBadAlloc);
+
+ /// Clear the state to 'NonThrowing' to make the corresponding entity
+ /// neutral.
+ void clear();
+
+ /// References the set of known exception types that can escape from the
+ /// corresponding entity.
+ const Throwables &getExceptionTypes() const { return ThrownExceptions; }
+
+ /// Signal if the there is any 'Unknown' element within the scope of
+ /// the related entity. This might be relevant if the entity is 'Throwing'
+ /// and to ensure that no other exception then 'getExceptionTypes' can
+ /// occur. If there is an 'Unknown' element this can not be guaranteed.
+ bool containsUnknownElements() const { return ContainsUnknown; }
+
+ private:
+ /// Recalculate the 'Behaviour' for example after filtering.
+ void reevaluateBehaviour();
+
+ /// Keep track if the entity related to this 'ExceptionInfo' can in princple
+ /// throw, if it's unknown or if it won't throw.
+ State Behaviour;
+
+ /// Keep track if the entity contains any unknown elements to keep track
+ /// of the certainty of decisions and/or correct 'Behaviour' transition
+ /// after filtering.
+ bool ContainsUnknown;
+
+ /// 'ThrownException' is empty if the 'Behaviour' is either 'NotThrowing' or
+ /// 'Unknown'.
+ Throwables ThrownExceptions;
+ };
+
+ ExceptionAnalyzer() = default;
+
+ void ignoreBadAlloc(bool ShallIgnore) { IgnoreBadAlloc = ShallIgnore; }
+ void ignoreExceptions(llvm::StringSet<> ExceptionNames) {
+ IgnoredExceptions = std::move(ExceptionNames);
+ }
+
+ ExceptionInfo analyze(const FunctionDecl *Func);
+ ExceptionInfo analyze(const Stmt *Stmt);
+
+private:
+ ExceptionInfo
+ throwsException(const FunctionDecl *Func,
+ llvm::SmallSet<const FunctionDecl *, 32> &CallStack);
+ ExceptionInfo
+ throwsException(const Stmt *St, const ExceptionInfo::Throwables &Caught,
+ llvm::SmallSet<const FunctionDecl *, 32> &CallStack);
+
+ ExceptionInfo analyzeImpl(const FunctionDecl *Func);
+ ExceptionInfo analyzeImpl(const Stmt *Stmt);
+
+ template <typename T> ExceptionInfo analyzeDispatch(const T *Node);
+
+ bool IgnoreBadAlloc = true;
+ llvm::StringSet<> IgnoredExceptions;
+ std::map<const FunctionDecl *, ExceptionInfo> FunctionCache;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/ExprSequence.h b/linux-x64/clang/include/clang-tidy/utils/ExprSequence.h
new file mode 100644
index 0000000..7bb87ad
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/ExprSequence.h
@@ -0,0 +1,124 @@
+//===------------- ExprSequence.h - clang-tidy ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_EXPRSEQUENCE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_EXPRSEQUENCE_H
+
+#include "clang/Analysis/CFG.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// Provides information about the evaluation order of (sub-)expressions within
+/// a `CFGBlock`.
+///
+/// While a `CFGBlock` does contain individual `CFGElement`s for some
+/// sub-expressions, the order in which those `CFGElement`s appear reflects
+/// only one possible order in which the sub-expressions may be evaluated.
+/// However, we want to warn if any of the potential evaluation orders can lead
+/// to a use-after-move, not just the one contained in the `CFGBlock`.
+///
+/// This class implements only a simplified version of the C++ sequencing
+/// rules. The main limitation is that we do not distinguish between value
+/// computation and side effect -- see the "Implementation" section for more
+/// details.
+///
+/// Note: `SequenceChecker` from SemaChecking.cpp does a similar job (and much
+/// more thoroughly), but using it would require
+/// - Pulling `SequenceChecker` out into a header file (i.e. making it part of
+/// the API),
+/// - Removing the dependency of `SequenceChecker` on `Sema`, and
+/// - (Probably) modifying `SequenceChecker` to make it suitable to be used in
+/// this context.
+/// For the moment, it seems preferable to re-implement our own version of
+/// sequence checking that is special-cased to what we need here.
+///
+/// Implementation
+/// --------------
+///
+/// `ExprSequence` uses two types of sequencing edges between nodes in the AST:
+///
+/// - Every `Stmt` is assumed to be sequenced after its children. This is
+/// overly optimistic because the standard only states that value computations
+/// of operands are sequenced before the value computation of the operator,
+/// making no guarantees about side effects (in general).
+///
+/// For our purposes, this rule is sufficient, however, because this check is
+/// interested in operations on objects, which are generally performed through
+/// function calls (whether explicit and implicit). Function calls guarantee
+/// that the value computations and side effects for all function arguments
+/// are sequenced before the execution of the function.
+///
+/// - In addition, some `Stmt`s are known to be sequenced before or after
+/// their siblings. For example, the `Stmt`s that make up a `CompoundStmt`are
+/// all sequenced relative to each other. The function
+/// `getSequenceSuccessor()` implements these sequencing rules.
+class ExprSequence {
+public:
+ /// Initializes this `ExprSequence` with sequence information for the given
+ /// `CFG`. `Root` is the root statement the CFG was built from.
+ ExprSequence(const CFG *TheCFG, const Stmt *Root, ASTContext *TheContext);
+
+ /// Returns whether \p Before is sequenced before \p After.
+ bool inSequence(const Stmt *Before, const Stmt *After) const;
+
+ /// Returns whether \p After can potentially be evaluated after \p Before.
+ /// This is exactly equivalent to `!inSequence(After, Before)` but makes some
+ /// conditions read more naturally.
+ bool potentiallyAfter(const Stmt *After, const Stmt *Before) const;
+
+private:
+ // Returns the sibling of \p S (if any) that is directly sequenced after \p S,
+ // or nullptr if no such sibling exists. For example, if \p S is the child of
+ // a `CompoundStmt`, this would return the Stmt that directly follows \p S in
+ // the `CompoundStmt`.
+ //
+ // As the sequencing of many constructs that change control flow is already
+ // encoded in the `CFG`, this function only implements the sequencing rules
+ // for those constructs where sequencing cannot be inferred from the `CFG`.
+ const Stmt *getSequenceSuccessor(const Stmt *S) const;
+
+ const Stmt *resolveSyntheticStmt(const Stmt *S) const;
+
+ ASTContext *Context;
+ const Stmt *Root;
+
+ llvm::DenseMap<const Stmt *, const Stmt *> SyntheticStmtSourceMap;
+};
+
+/// Maps `Stmt`s to the `CFGBlock` that contains them. Some `Stmt`s may be
+/// contained in more than one `CFGBlock`; in this case, they are mapped to the
+/// innermost block (i.e. the one that is furthest from the root of the tree).
+class StmtToBlockMap {
+public:
+ /// Initializes the map for the given `CFG`.
+ StmtToBlockMap(const CFG *TheCFG, ASTContext *TheContext);
+
+ /// Returns the block that \p S is contained in. Some `Stmt`s may be contained
+ /// in more than one `CFGBlock`; in this case, this function returns the
+ /// innermost block (i.e. the one that is furthest from the root of the tree).
+ const CFGBlock *blockContainingStmt(const Stmt *S) const;
+
+private:
+ ASTContext *Context;
+
+ llvm::DenseMap<const Stmt *, const CFGBlock *> Map;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_EXPRSEQUENCE_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/FileExtensionsUtils.h b/linux-x64/clang/include/clang-tidy/utils/FileExtensionsUtils.h
new file mode 100644
index 0000000..26184a5
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/FileExtensionsUtils.h
@@ -0,0 +1,68 @@
+//===--- FileExtensionsUtils.h - clang-tidy --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+typedef llvm::SmallSet<llvm::StringRef, 5> FileExtensionsSet;
+
+/// Checks whether expansion location of \p Loc is in header file.
+bool isExpansionLocInHeaderFile(SourceLocation Loc, const SourceManager &SM,
+ const FileExtensionsSet &HeaderFileExtensions);
+
+/// Checks whether presumed location of \p Loc is in header file.
+bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM,
+ const FileExtensionsSet &HeaderFileExtensions);
+
+/// Checks whether spelling location of \p Loc is in header file.
+bool isSpellingLocInHeaderFile(SourceLocation Loc, SourceManager &SM,
+ const FileExtensionsSet &HeaderFileExtensions);
+
+/// Returns recommended default value for the list of header file
+/// extensions.
+inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
+
+/// Returns recommended default value for the list of implementation file
+/// extensions.
+inline StringRef defaultImplementationFileExtensions() {
+ return "c;cc;cpp;cxx";
+}
+
+/// Returns recommended default value for the list of file extension
+/// delimiters.
+inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
+
+/// Parses header file extensions from a semicolon-separated list.
+bool parseFileExtensions(StringRef AllFileExtensions,
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);
+
+/// Decides whether a file has a header file extension.
+/// Returns the file extension, if included in the provided set.
+llvm::Optional<StringRef>
+getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions);
+
+/// Decides whether a file has one of the specified file extensions.
+bool isFileExtension(StringRef FileName,
+ const FileExtensionsSet &FileExtensions);
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/FixItHintUtils.h b/linux-x64/clang/include/clang-tidy/utils/FixItHintUtils.h
new file mode 100644
index 0000000..2f5a741
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/FixItHintUtils.h
@@ -0,0 +1,54 @@
+//===--- FixItHintUtils.h - clang-tidy---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/Sema/DeclSpec.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace fixit {
+
+/// Creates fix to make ``VarDecl`` a reference by adding ``&``.
+FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context);
+
+/// This enum defines where the qualifier shall be preferably added.
+enum class QualifierPolicy {
+ Left, // Add the qualifier always to the left side, if that is possible.
+ Right, // Add the qualifier always to the right side.
+};
+
+/// This enum defines which entity is the target for adding the qualifier. This
+/// makes only a difference for pointer-types. Other types behave identical
+/// for either value of \c ConstTarget.
+enum class QualifierTarget {
+ Pointee, /// Transforming a pointer attaches to the pointee and not the
+ /// pointer itself. For references and normal values this option has
+ /// no effect. `int * p = &i;` -> `const int * p = &i` or `int const
+ /// * p = &i`.
+ Value, /// Transforming pointers will consider the pointer itself.
+ /// `int * p = &i;` -> `int * const = &i`
+};
+
+/// \brief Creates fix to qualify ``VarDecl`` with the specified \c Qualifier.
+/// Requires that `Var` is isolated in written code like in `int foo = 42;`.
+Optional<FixItHint>
+addQualifierToVarDecl(const VarDecl &Var, const ASTContext &Context,
+ DeclSpec::TQ Qualifier,
+ QualifierTarget CT = QualifierTarget::Pointee,
+ QualifierPolicy CP = QualifierPolicy::Left);
+} // namespace fixit
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/HeaderGuard.h b/linux-x64/clang/include/clang-tidy/utils/HeaderGuard.h
new file mode 100644
index 0000000..86c0f3d
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/HeaderGuard.h
@@ -0,0 +1,67 @@
+//===--- HeaderGuard.h - clang-tidy -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/FileExtensionsUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// Finds and fixes header guards.
+/// The check supports these options:
+/// - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
+/// For extension-less header files, using an empty string or leaving an
+/// empty string between ";" if there are other filename extensions.
+class HeaderGuardCheck : public ClangTidyCheck {
+public:
+ HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+ "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
+ utils::parseFileExtensions(RawStringHeaderFileExtensions,
+ HeaderFileExtensions,
+ utils::defaultFileExtensionDelimiters());
+ }
+ void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
+
+ /// Returns ``true`` if the check should suggest inserting a trailing comment
+ /// on the ``#endif`` of the header guard. It will use the same name as
+ /// returned by ``HeaderGuardCheck::getHeaderGuard``.
+ virtual bool shouldSuggestEndifComment(StringRef Filename);
+ /// Returns ``true`` if the check should suggest changing an existing header
+ /// guard to the string returned by ``HeaderGuardCheck::getHeaderGuard``.
+ virtual bool shouldFixHeaderGuard(StringRef Filename);
+ /// Returns ``true`` if the check should add a header guard to the file
+ /// if it has none.
+ virtual bool shouldSuggestToAddHeaderGuard(StringRef Filename);
+ /// Returns a replacement for the ``#endif`` line with a comment mentioning
+ /// \p HeaderGuard. The replacement should start with ``endif``.
+ virtual std::string formatEndIf(StringRef HeaderGuard);
+ /// Gets the canonical header guard for a file.
+ virtual std::string getHeaderGuard(StringRef Filename,
+ StringRef OldGuard = StringRef()) = 0;
+
+private:
+ std::string RawStringHeaderFileExtensions;
+ utils::FileExtensionsSet HeaderFileExtensions;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADERGUARD_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/IncludeInserter.h b/linux-x64/clang/include/clang-tidy/utils/IncludeInserter.h
new file mode 100644
index 0000000..74903b2
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/IncludeInserter.h
@@ -0,0 +1,102 @@
+//===---------- IncludeInserter.h - clang-tidy ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDEINSERTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDEINSERTER_H
+
+#include "IncludeSorter.h"
+#include "clang/Basic/Diagnostic.h"
+#include "llvm/ADT/StringSet.h"
+#include <memory>
+
+namespace clang {
+class Preprocessor;
+namespace tidy {
+namespace utils {
+
+/// Produces fixes to insert specified includes to source files, if not
+/// yet present.
+///
+/// ``IncludeInserter`` can be used in clang-tidy checks in the following way:
+/// \code
+/// #include "../ClangTidyCheck.h"
+/// #include "../utils/IncludeInserter.h"
+///
+/// namespace clang {
+/// namespace tidy {
+///
+/// class MyCheck : public ClangTidyCheck {
+/// public:
+/// void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+/// Preprocessor *ModuleExpanderPP) override {
+/// Inserter.registerPreprocessor(PP);
+/// }
+///
+/// void registerMatchers(ast_matchers::MatchFinder* Finder) override { ... }
+///
+/// void check(
+/// const ast_matchers::MatchFinder::MatchResult& Result) override {
+/// ...
+/// Inserter.createMainFileIncludeInsertion("path/to/Header.h");
+/// ...
+/// }
+///
+/// private:
+/// utils::IncludeInserter Inserter{utils::IncludeSorter::IS_Google};
+/// };
+/// } // namespace tidy
+/// } // namespace clang
+/// \endcode
+class IncludeInserter {
+public:
+ /// Initializes the IncludeInserter using the IncludeStyle \p Style.
+ /// In most cases the \p Style will be retrieved from the ClangTidyOptions
+ /// using \code
+ /// Options.getLocalOrGlobal("IncludeStyle", <DefaultStyle>)
+ /// \endcode
+ explicit IncludeInserter(IncludeSorter::IncludeStyle Style);
+
+ /// Registers this with the Preprocessor \p PP, must be called before this
+ /// class is used.
+ void registerPreprocessor(Preprocessor *PP);
+
+ /// Creates a \p Header inclusion directive fixit in the File \p FileID.
+ /// When \p Header is enclosed in angle brackets, uses angle brackets in the
+ /// inclusion directive, otherwise uses quotes.
+ /// Returns ``llvm::None`` on error or if the inclusion directive already
+ /// exists.
+ llvm::Optional<FixItHint> createIncludeInsertion(FileID FileID,
+ llvm::StringRef Header);
+
+ /// Creates a \p Header inclusion directive fixit in the main file.
+ /// When \p Header is enclosed in angle brackets, uses angle brackets in the
+ /// inclusion directive, otherwise uses quotes.
+ /// Returns ``llvm::None`` on error or if the inclusion directive already
+ /// exists.
+ llvm::Optional<FixItHint>
+ createMainFileIncludeInsertion(llvm::StringRef Header);
+
+ IncludeSorter::IncludeStyle getStyle() const { return Style; }
+
+private:
+ void addInclude(StringRef FileName, bool IsAngled,
+ SourceLocation HashLocation, SourceLocation EndLocation);
+
+ IncludeSorter &getOrCreate(FileID FileID);
+
+ llvm::DenseMap<FileID, std::unique_ptr<IncludeSorter>> IncludeSorterByFile;
+ llvm::DenseMap<FileID, llvm::StringSet<>> InsertedHeaders;
+ const SourceManager *SourceMgr{nullptr};
+ const IncludeSorter::IncludeStyle Style;
+ friend class IncludeInserterCallback;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDEINSERTER_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/IncludeSorter.h b/linux-x64/clang/include/clang-tidy/utils/IncludeSorter.h
new file mode 100644
index 0000000..a8cf18c
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/IncludeSorter.h
@@ -0,0 +1,75 @@
+//===------------ IncludeSorter.h - clang-tidy ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
+
+#include "../ClangTidyCheck.h"
+#include <string>
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// Class used by ``IncludeInserterCallback`` to record the names of the
+/// inclusions in a given source file being processed and generate the necessary
+/// commands to sort the inclusions according to the precedence encoded in
+/// ``IncludeKinds``.
+class IncludeSorter {
+public:
+ /// Supported include styles.
+ enum IncludeStyle { IS_LLVM = 0, IS_Google = 1, IS_Google_ObjC };
+
+ /// The classifications of inclusions, in the order they should be sorted.
+ enum IncludeKinds {
+ IK_MainTUInclude = 0, ///< e.g. ``#include "foo.h"`` when editing foo.cc
+ IK_CSystemInclude = 1, ///< e.g. ``#include <stdio.h>``
+ IK_CXXSystemInclude = 2, ///< e.g. ``#include <vector>``
+ IK_NonSystemInclude = 3, ///< e.g. ``#include "bar.h"``
+ IK_GeneratedInclude = 4, ///< e.g. ``#include "bar.proto.h"``
+ IK_InvalidInclude = 5 ///< total number of valid ``IncludeKind``s
+ };
+
+ /// ``IncludeSorter`` constructor; takes the FileID and name of the file to be
+ /// processed by the sorter.
+ IncludeSorter(const SourceManager *SourceMgr, const FileID FileID,
+ StringRef FileName, IncludeStyle Style);
+
+ /// Adds the given include directive to the sorter.
+ void AddInclude(StringRef FileName, bool IsAngled,
+ SourceLocation HashLocation, SourceLocation EndLocation);
+
+ /// Creates a quoted inclusion directive in the right sort order. Returns None
+ /// on error or if header inclusion directive for header already exists.
+ Optional<FixItHint> CreateIncludeInsertion(StringRef FileName, bool IsAngled);
+
+private:
+ typedef SmallVector<SourceRange, 1> SourceRangeVector;
+
+ const SourceManager *SourceMgr;
+ const IncludeStyle Style;
+ FileID CurrentFileID;
+ /// The file name stripped of common suffixes.
+ StringRef CanonicalFile;
+ /// Locations of visited include directives.
+ SourceRangeVector SourceLocations;
+ /// Mapping from file name to #include locations.
+ llvm::StringMap<SourceRangeVector> IncludeLocations;
+ /// Includes sorted into buckets.
+ SmallVector<std::string, 1> IncludeBucket[IK_InvalidInclude];
+};
+
+} // namespace utils
+
+template <> struct OptionEnumMapping<utils::IncludeSorter::IncludeStyle> {
+ static ArrayRef<std::pair<utils::IncludeSorter::IncludeStyle, StringRef>>
+ getEnumMapping();
+};
+} // namespace tidy
+} // namespace clang
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/LexerUtils.h b/linux-x64/clang/include/clang-tidy/utils/LexerUtils.h
new file mode 100644
index 0000000..8781b05
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/LexerUtils.h
@@ -0,0 +1,112 @@
+//===--- LexerUtils.h - clang-tidy-------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace lexer {
+
+/// Returns previous token or ``tok::unknown`` if not found.
+Token getPreviousToken(SourceLocation Location, const SourceManager &SM,
+ const LangOptions &LangOpts, bool SkipComments = true);
+
+SourceLocation findPreviousTokenStart(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts);
+
+SourceLocation findPreviousTokenKind(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts,
+ tok::TokenKind TK);
+
+SourceLocation findNextTerminator(SourceLocation Start, const SourceManager &SM,
+ const LangOptions &LangOpts);
+
+template <typename TokenKind, typename... TokenKinds>
+SourceLocation findPreviousAnyTokenKind(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts,
+ TokenKind TK, TokenKinds... TKs) {
+ if (Start.isInvalid() || Start.isMacroID())
+ return SourceLocation();
+ while (true) {
+ SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
+ if (L.isInvalid() || L.isMacroID())
+ return SourceLocation();
+
+ Token T;
+ // Returning 'true' is used to signal failure to retrieve the token.
+ if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
+ return SourceLocation();
+
+ if (T.isOneOf(TK, TKs...))
+ return T.getLocation();
+
+ Start = L;
+ }
+}
+
+template <typename TokenKind, typename... TokenKinds>
+SourceLocation findNextAnyTokenKind(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts, TokenKind TK,
+ TokenKinds... TKs) {
+ while (true) {
+ Optional<Token> CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
+
+ if (!CurrentToken)
+ return SourceLocation();
+
+ Token PotentialMatch = *CurrentToken;
+ if (PotentialMatch.isOneOf(TK, TKs...))
+ return PotentialMatch.getLocation();
+
+ // If we reach the end of the file, and eof is not the target token, we stop
+ // the loop, otherwise we will get infinite loop (findNextToken will return
+ // eof on eof).
+ if (PotentialMatch.is(tok::eof))
+ return SourceLocation();
+ Start = PotentialMatch.getLastLoc();
+ }
+}
+
+// Finds next token that's not a comment.
+Optional<Token> findNextTokenSkippingComments(SourceLocation Start,
+ const SourceManager &SM,
+ const LangOptions &LangOpts);
+
+/// Re-lex the provide \p Range and return \c false if either a macro spans
+/// multiple tokens, a pre-processor directive or failure to retrieve the
+/// next token is found, otherwise \c true.
+bool rangeContainsExpansionsOrDirectives(SourceRange Range,
+ const SourceManager &SM,
+ const LangOptions &LangOpts);
+
+/// Assuming that ``Range`` spans a CVR-qualified type, returns the
+/// token in ``Range`` that is responsible for the qualification. ``Range``
+/// must be valid with respect to ``SM``. Returns ``None`` if no qualifying
+/// tokens are found.
+/// \note: doesn't support member function qualifiers.
+llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
+ CharSourceRange Range,
+ const ASTContext &Context,
+ const SourceManager &SM);
+
+} // namespace lexer
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/Matchers.h b/linux-x64/clang/include/clang-tidy/utils/Matchers.h
new file mode 100644
index 0000000..9b765ae
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/Matchers.h
@@ -0,0 +1,63 @@
+//===--- Matchers.h - clang-tidy-------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
+
+#include "TypeTraits.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+namespace clang {
+namespace tidy {
+namespace matchers {
+
+AST_MATCHER(BinaryOperator, isRelationalOperator) {
+ return Node.isRelationalOp();
+}
+
+AST_MATCHER(BinaryOperator, isEqualityOperator) { return Node.isEqualityOp(); }
+
+AST_MATCHER(QualType, isExpensiveToCopy) {
+ llvm::Optional<bool> IsExpensive =
+ utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
+ return IsExpensive && *IsExpensive;
+}
+
+AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) {
+ return utils::type_traits::recordIsTriviallyDefaultConstructible(
+ Node, Finder->getASTContext());
+}
+
+AST_MATCHER(QualType, isTriviallyDestructible) {
+ return utils::type_traits::isTriviallyDestructible(Node);
+}
+
+// Returns QualType matcher for references to const.
+AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isReferenceToConst) {
+ using namespace ast_matchers;
+ return referenceType(pointee(qualType(isConstQualified())));
+}
+
+// Returns QualType matcher for pointers to const.
+AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {
+ using namespace ast_matchers;
+ return pointerType(pointee(qualType(isConstQualified())));
+}
+
+AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector<std::string>,
+ NameList) {
+ return llvm::any_of(NameList, [&Node](const std::string &Name) {
+ return llvm::Regex(Name).match(Node.getName());
+ });
+}
+
+} // namespace matchers
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_MATCHERS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/NamespaceAliaser.h b/linux-x64/clang/include/clang-tidy/utils/NamespaceAliaser.h
new file mode 100644
index 0000000..ab1b978
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/NamespaceAliaser.h
@@ -0,0 +1,51 @@
+//===---------- NamespaceAliaser.h - clang-tidy ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NAMESPACEALIASER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NAMESPACEALIASER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+#include <map>
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// This class creates function-level namespace aliases.
+class NamespaceAliaser {
+public:
+ explicit NamespaceAliaser(const SourceManager &SourceMgr);
+ // Adds a namespace alias for \p Namespace valid near \p
+ // Statement. Picks the first available name from \p Abbreviations.
+ // Returns ``llvm::None`` if an alias already exists or there is an error.
+ llvm::Optional<FixItHint>
+ createAlias(ASTContext &Context, const Stmt &Statement,
+ llvm::StringRef Namespace,
+ const std::vector<std::string> &Abbreviations);
+
+ // Get an alias name for \p Namespace valid at \p Statement. Returns \p
+ // Namespace if there is no alias.
+ std::string getNamespaceName(ASTContext &Context, const Stmt &Statement,
+ llvm::StringRef Namespace) const;
+
+private:
+ const SourceManager &SourceMgr;
+ llvm::DenseMap<const FunctionDecl *, llvm::StringMap<std::string>>
+ AddedAliases;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NAMESPACEALIASER_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/OptionsUtils.h b/linux-x64/clang/include/clang-tidy/utils/OptionsUtils.h
new file mode 100644
index 0000000..5f83747
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/OptionsUtils.h
@@ -0,0 +1,31 @@
+//===--- DanglingHandleCheck.h - clang-tidy----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace options {
+
+/// Parse a semicolon separated list of strings.
+std::vector<std::string> parseStringList(StringRef Option);
+
+/// Serialize a sequence of names that can be parsed by
+/// ``parseStringList``.
+std::string serializeStringList(ArrayRef<std::string> Strings);
+
+} // namespace options
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/RenamerClangTidyCheck.h b/linux-x64/clang/include/clang-tidy/utils/RenamerClangTidyCheck.h
new file mode 100644
index 0000000..fd5b320
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -0,0 +1,165 @@
+//===--- RenamderClangTidyCheck.h - clang-tidy ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_RENAMERCLANGTIDYCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_RENAMERCLANGTIDYCHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include "llvm/ADT/Optional.h"
+#include <string>
+#include <utility>
+
+namespace clang {
+
+class MacroInfo;
+
+namespace tidy {
+
+/// Base class for clang-tidy checks that want to flag declarations and/or
+/// macros for renaming based on customizable criteria.
+class RenamerClangTidyCheck : public ClangTidyCheck {
+public:
+ RenamerClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
+ ~RenamerClangTidyCheck();
+
+ /// Derived classes should not implement any matching logic themselves; this
+ /// class will do the matching and call the derived class'
+ /// GetDeclFailureInfo() and GetMacroFailureInfo() for determining whether a
+ /// given identifier passes or fails the check.
+ void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
+ void
+ check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override final;
+ void onEndOfTranslationUnit() override final;
+
+ /// Derived classes that override this function should call this method from
+ /// the overridden method.
+ void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+ /// This enum will be used in %select of the diagnostic message.
+ /// Each value below IgnoreFailureThreshold should have an error message.
+ enum class ShouldFixStatus {
+ ShouldFix,
+
+ /// The fixup will conflict with a language keyword,
+ /// so we can't fix it automatically.
+ ConflictsWithKeyword,
+
+ /// The fixup will conflict with a macro
+ /// definition, so we can't fix it
+ /// automatically.
+ ConflictsWithMacroDefinition,
+
+ /// The fixup results in an identifier that is not a valid c/c++ identifier.
+ FixInvalidIdentifier,
+
+ /// Values pass this threshold will be ignored completely
+ /// i.e no message, no fixup.
+ IgnoreFailureThreshold,
+
+ /// If the identifier was used or declared within a macro we
+ /// won't offer a fixup for safety reasons.
+ InsideMacro,
+ };
+
+ /// Information describing a failed check
+ struct FailureInfo {
+ std::string KindName; // Tag or misc info to be used as derived classes need
+ std::string Fixup; // The name that will be proposed as a fix-it hint
+ };
+
+ /// Holds an identifier name check failure, tracking the kind of the
+ /// identifier, its possible fixup and the starting locations of all the
+ /// identifier usages.
+ struct NamingCheckFailure {
+ FailureInfo Info;
+
+ /// Whether the failure should be fixed or not.
+ ///
+ /// e.g.: if the identifier was used or declared within a macro we won't
+ /// offer a fixup for safety reasons.
+ bool ShouldFix() const {
+ return FixStatus == ShouldFixStatus::ShouldFix && !Info.Fixup.empty();
+ }
+
+ bool ShouldNotify() const {
+ return FixStatus < ShouldFixStatus::IgnoreFailureThreshold;
+ }
+
+ ShouldFixStatus FixStatus = ShouldFixStatus::ShouldFix;
+
+ /// A set of all the identifier usages starting SourceLocation.
+ llvm::DenseSet<SourceLocation> RawUsageLocs;
+
+ NamingCheckFailure() = default;
+ };
+
+ using NamingCheckId = std::pair<SourceLocation, std::string>;
+
+ using NamingCheckFailureMap =
+ llvm::DenseMap<NamingCheckId, NamingCheckFailure>;
+
+ /// Check Macros for style violations.
+ void checkMacro(SourceManager &sourceMgr, const Token &MacroNameTok,
+ const MacroInfo *MI);
+
+ /// Add a usage of a macro if it already has a violation.
+ void expandMacro(const Token &MacroNameTok, const MacroInfo *MI);
+
+ void addUsage(const RenamerClangTidyCheck::NamingCheckId &Decl,
+ SourceRange Range, SourceManager *SourceMgr = nullptr);
+
+ /// Convenience method when the usage to be added is a NamedDecl.
+ void addUsage(const NamedDecl *Decl, SourceRange Range,
+ SourceManager *SourceMgr = nullptr);
+
+protected:
+ /// Overridden by derived classes, returns information about if and how a Decl
+ /// failed the check. A 'None' result means the Decl did not fail the check.
+ virtual llvm::Optional<FailureInfo>
+ GetDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const = 0;
+
+ /// Overridden by derived classes, returns information about if and how a
+ /// macro failed the check. A 'None' result means the macro did not fail the
+ /// check.
+ virtual llvm::Optional<FailureInfo>
+ GetMacroFailureInfo(const Token &MacroNameTok,
+ const SourceManager &SM) const = 0;
+
+ /// Represents customized diagnostic text and how arguments should be applied.
+ /// Example usage:
+ ///
+ /// return DiagInfo{"my %1 very %2 special %3 text",
+ /// [=](DiagnosticBuilder &diag) {
+ /// diag << arg1 << arg2 << arg3;
+ /// }};
+ struct DiagInfo {
+ std::string Text;
+ llvm::unique_function<void(DiagnosticBuilder &)> ApplyArgs;
+ };
+
+ /// Overridden by derived classes, returns a description of the diagnostic
+ /// that should be emitted for the given failure. The base class will then
+ /// further customize the diagnostic by adding info about whether the fix-it
+ /// can be automatically applied or not.
+ virtual DiagInfo GetDiagInfo(const NamingCheckId &ID,
+ const NamingCheckFailure &Failure) const = 0;
+
+private:
+ NamingCheckFailureMap NamingCheckFailures;
+ const bool AggressiveDependentMemberLookup;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_RENAMERCLANGTIDYCHECK_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/TransformerClangTidyCheck.h b/linux-x64/clang/include/clang-tidy/utils/TransformerClangTidyCheck.h
new file mode 100644
index 0000000..9736e64
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -0,0 +1,88 @@
+//===---------- TransformerClangTidyCheck.h - clang-tidy ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_CLANG_TIDY_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_CLANG_TIDY_CHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "IncludeInserter.h"
+#include "IncludeSorter.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Transformer/Transformer.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// A base class for defining a ClangTidy check based on a `RewriteRule`.
+//
+// For example, given a rule `MyCheckAsRewriteRule`, one can define a tidy check
+// as follows:
+//
+// class MyCheck : public TransformerClangTidyCheck {
+// public:
+// MyCheck(StringRef Name, ClangTidyContext *Context)
+// : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {}
+// };
+//
+// `TransformerClangTidyCheck` recognizes this clang-tidy option:
+//
+// * IncludeStyle. A string specifying which file naming convention is used by
+// the source code, 'llvm' or 'google'. Default is 'llvm'. The naming
+// convention influences how canonical headers are distinguished from other
+// includes.
+class TransformerClangTidyCheck : public ClangTidyCheck {
+public:
+ TransformerClangTidyCheck(StringRef Name, ClangTidyContext *Context);
+
+ /// DEPRECATED: prefer the two argument constructor in conjunction with
+ /// \c setRule.
+ ///
+ /// \p MakeRule generates the rewrite rule to be used by the check, based on
+ /// the given language and clang-tidy options. It can return \c None to handle
+ /// cases where the options disable the check.
+ ///
+ /// See \c setRule for constraints on the rule.
+ TransformerClangTidyCheck(std::function<Optional<transformer::RewriteRule>(
+ const LangOptions &, const OptionsView &)>
+ MakeRule,
+ StringRef Name, ClangTidyContext *Context);
+
+ /// Convenience overload of the constructor when the rule doesn't have any
+ /// dependies.
+ TransformerClangTidyCheck(transformer::RewriteRule R, StringRef Name,
+ ClangTidyContext *Context);
+
+ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+ Preprocessor *ModuleExpanderPP) override;
+ void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+ void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
+
+ /// Derived classes that override this function should call this method from
+ /// the overridden method.
+ void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+ /// Set the rule that this check implements. All cases in the rule must have
+ /// a non-null \c Explanation, even though \c Explanation is optional for
+ /// RewriteRule in general. Because the primary purpose of clang-tidy checks
+ /// is to provide users with diagnostics, we assume that a missing explanation
+ /// is a bug. If no explanation is desired, indicate that explicitly (for
+ /// example, by passing `text("no explanation")` to `makeRule` as the
+ /// `Explanation` argument).
+ void setRule(transformer::RewriteRule R);
+
+private:
+ transformer::RewriteRule Rule;
+ IncludeInserter Inserter;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_CLANG_TIDY_CHECK_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/TypeTraits.h b/linux-x64/clang/include/clang-tidy/utils/TypeTraits.h
new file mode 100644
index 0000000..f4d3455
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/TypeTraits.h
@@ -0,0 +1,45 @@
+//===--- TypeTraits.h - clang-tidy-------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_TYPETRAITS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_TYPETRAITS_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace type_traits {
+
+/// Returns `true` if `Type` is expensive to copy.
+llvm::Optional<bool> isExpensiveToCopy(QualType Type,
+ const ASTContext &Context);
+
+/// Returns `true` if `Type` is trivially default constructible.
+bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context);
+
+/// Returns `true` if `RecordDecl` is trivially default constructible.
+bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl,
+ const ASTContext &Context);
+
+/// Returns `true` if `Type` is trivially destructible.
+bool isTriviallyDestructible(QualType Type);
+
+/// Returns true if `Type` has a non-trivial move constructor.
+bool hasNonTrivialMoveConstructor(QualType Type);
+
+/// Return true if `Type` has a non-trivial move assignment operator.
+bool hasNonTrivialMoveAssignment(QualType Type);
+
+} // type_traits
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_TYPETRAITS_H
diff --git a/linux-x64/clang/include/clang-tidy/utils/UsingInserter.h b/linux-x64/clang/include/clang-tidy/utils/UsingInserter.h
new file mode 100644
index 0000000..9d3c60c
--- /dev/null
+++ b/linux-x64/clang/include/clang-tidy/utils/UsingInserter.h
@@ -0,0 +1,49 @@
+//===---------- UsingInserter.h - clang-tidy ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_USINGINSERTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_USINGINSERTER_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+#include <set>
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// UsingInserter adds using declarations for |QualifiedName| to the surrounding
+// function.
+// This allows using a shorter name without clobbering other scopes.
+class UsingInserter {
+public:
+ UsingInserter(const SourceManager &SourceMgr);
+
+ // Creates a \p using declaration fixit. Returns ``llvm::None`` on error
+ // or if the using declaration already exists.
+ llvm::Optional<FixItHint>
+ createUsingDeclaration(ASTContext &Context, const Stmt &Statement,
+ llvm::StringRef QualifiedName);
+
+ // Returns the unqualified version of the name if there is an
+ // appropriate using declaration and the qualified name otherwise.
+ llvm::StringRef getShortName(ASTContext &Context, const Stmt &Statement,
+ llvm::StringRef QualifiedName);
+
+private:
+ typedef std::pair<const FunctionDecl *, std::string> NameInFunction;
+ const SourceManager &SourceMgr;
+ std::set<NameInFunction> AddedUsing;
+};
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_USINGINSERTER_H