Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (#697)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in llvm/lib/Support/Triple.cpp
  CONFLICT (content): Merge conflict in llvm/include/llvm/ADT/Triple.h
  • Loading branch information
sndmitriev committed Jan 10, 2020
2 parents edaf01d + ff0311c commit c2c98c9
Show file tree
Hide file tree
Showing 1,757 changed files with 90,064 additions and 44,801 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
// FIXME: This will report conflicts by pair using a file+offset format
// which is not so much human readable.
// A first improvement could be to translate offset to line+col. For
// this and without loosing error message some modifications arround
// this and without loosing error message some modifications around
// `tooling::ReplacementError` are need (access to
// `getReplacementErrString`).
// A better strategy could be to add a pretty printer methods for
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/BitcodeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ClangDocBitcodeReader {
// or block to be read.
Cursor skipUntilRecordOrBlock(unsigned &BlockOrRecordID);

// Helper function to set up the approriate type of Info.
// Helper function to set up the appropriate type of Info.
llvm::Expected<std::unique_ptr<Info>> readBlockToInfo(unsigned ID);

llvm::BitstreamCursor &Stream;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/MDGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void genMarkdown(const RecordInfo &I, llvm::raw_ostream &OS) {

if (!I.Members.empty()) {
writeHeader("Members", 2, OS);
for (const auto Member : I.Members) {
for (const auto &Member : I.Members) {
std::string Access = getAccess(Member.Access);
if (Access != "")
writeLine(Access + " " + Member.Type.Name + " " + Member.Name, OS);
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/Representation.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct Reference {
bool mergeable(const Reference &Other);
void merge(Reference &&I);

SymbolID USR = SymbolID(); // Unique identifer for referenced decl
SymbolID USR = SymbolID(); // Unique identifier for referenced decl
SmallString<16> Name; // Name of type (possibly unresolved).
InfoType RefType = InfoType::IT_default; // Indicates the type of this
// Reference (namespace, record,
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/Serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
// A function to extract the appropriate relative path for a given info's
// documentation. The path returned is a composite of the parent namespaces.
//
// Example: Given the below, the diretory path for class C info will be
// Example: Given the below, the directory path for class C info will be
// <root>/A/B
//
// namespace A {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
// This tool for generating C and C++ documenation from source code
// This tool for generating C and C++ documentation from source code
// and comments. Generally, it runs a LibTooling FrontendAction on source files,
// mapping each declaration in those files to its USR and serializing relevant
// information into LLVM bitcode. It then runs a pass over the collected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::string createQualifiedNameForReplacement(
llvm::StringRef RawSymbolName,
llvm::StringRef SymbolScopedQualifiersName,
const find_all_symbols::SymbolInfo &MatchedSymbol) {
// No need to add missing qualifiers if SymbolIndentifer has a global scope
// No need to add missing qualifiers if SymbolIdentifier has a global scope
// operator "::".
if (RawSymbolName.startswith("::"))
return RawSymbolName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ buffer as only argument."
nil)

(defun clang-include-fixer--make-process (callback args)
"Start a new clang-incude-fixer process using `make-process'.
"Start a new clang-include-fixer process using `make-process'.
CALLBACK is called after the process finishes successfully; it is
called with a single argument, the buffer where standard output
has been inserted. ARGS is a list of additional command line
Expand All @@ -129,7 +129,7 @@ arguments. Return the new process object."
:stderr stderr)))

(defun clang-include-fixer--start-process (callback args)
"Start a new clang-incude-fixer process using `start-file-process'.
"Start a new clang-include-fixer process using `start-file-process'.
CALLBACK is called after the process finishes successfully; it is
called with a single argument, the buffer where standard output
has been inserted. ARGS is a list of additional command line
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-move/tool/ClangMove.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- ClangMove.cpp - move defintion to new file --------------*- C++ -*-===//
//===-- ClangMove.cpp - move definition to new file -------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-query/QueryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ QueryRef QueryParser::doParse() {
return completeMatcherExpression();

Diagnostics Diag;
auto MatcherSource = Line.trim();
auto MatcherSource = Line.ltrim();
auto OrigMatcherSource = MatcherSource;
Optional<DynTypedMatcher> Matcher = Parser::parseMatcherExpression(
MatcherSource, nullptr, &QS.NamedValues, &Diag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {
expr(ignoringParenCasts(stringLiteral(lengthIsOne()).bind("Literal")));

// Binds to a string_view (either absl or std) that was passed by value and
// contructed from string literal.
// constructed from string literal.
auto StringViewArg = ignoringElidableConstructorCall(ignoringImpCasts(
cxxConstructExpr(hasType(recordDecl(hasName("::absl::string_view"))),
hasArgument(0, ignoringParenImpCasts(SingleChar)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
!InsideMacroDefinition(Result, MaybeCallArg->getSourceRange())) {
// Handle the case where the matched expression is inside a call which
// converts it from the inverse to a Duration. In this case, we replace
// the outer with just the subtraction expresison, which gives the right
// the outer with just the subtraction expression, which gives the right
// type and scale, taking care again about parenthesis.
bool NeedParens = parensRequired(Result, MaybeCallArg);

Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "NotNullTerminatedResultCheck.h"
#include "ParentVirtualCallCheck.h"
#include "PosixReturnCheck.h"
#include "SignedCharMisuseCheck.h"
#include "SizeofContainerCheck.h"
#include "SizeofExpressionCheck.h"
#include "StringConstructorCheck.h"
Expand Down Expand Up @@ -119,6 +120,8 @@ class BugproneModule : public ClangTidyModule {
"bugprone-parent-virtual-call");
CheckFactories.registerCheck<PosixReturnCheck>(
"bugprone-posix-return");
CheckFactories.registerCheck<SignedCharMisuseCheck>(
"bugprone-signed-char-misuse");
CheckFactories.registerCheck<SizeofContainerCheck>(
"bugprone-sizeof-container");
CheckFactories.registerCheck<SizeofExpressionCheck>(
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_clang_library(clangTidyBugproneModule
NotNullTerminatedResultCheck.cpp
ParentVirtualCallCheck.cpp
PosixReturnCheck.cpp
SignedCharMisuseCheck.cpp
SizeofContainerCheck.cpp
SizeofExpressionCheck.cpp
StringConstructorCheck.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ForwardDeclarationNamespaceCheck::check(
const auto *Decl = Result.Nodes.getNodeAs<FriendDecl>("friend_decl");
assert(Decl && "Decl is neither record_decl nor friend decl!");

// Classes used in friend delarations are not marked referenced in AST,
// Classes used in friend declarations are not marked referenced in AST,
// so we need to check classes used in friend declarations manually to
// reduce the rate of false positive.
// For example, in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static bool isDestExprFix(const MatchFinder::MatchResult &Result,
}

// If the destination array is the same length as the given length we have to
// increase the capacity by one to create space for the the null terminator.
// increase the capacity by one to create space for the null terminator.
static bool isDestCapacityFix(const MatchFinder::MatchResult &Result,
DiagnosticBuilder &Diag) {
bool IsOverflows = isDestCapacityOverflows(Result);
Expand Down
104 changes: 104 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//===--- SignedCharMisuseCheck.cpp - 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
//
//===----------------------------------------------------------------------===//

#include "SignedCharMisuseCheck.h"
#include "../utils/OptionsUtils.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

using namespace clang::ast_matchers;
using namespace clang::ast_matchers::internal;

namespace clang {
namespace tidy {
namespace bugprone {

static Matcher<TypedefDecl> hasAnyListedName(const std::string &Names) {
const std::vector<std::string> NameList =
utils::options::parseStringList(Names);
return hasAnyName(std::vector<StringRef>(NameList.begin(), NameList.end()));
}

SignedCharMisuseCheck::SignedCharMisuseCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
CharTypdefsToIgnoreList(Options.get("CharTypdefsToIgnore", "")) {}

void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "CharTypdefsToIgnore", CharTypdefsToIgnoreList);
}

void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) {
// We can ignore typedefs which are some kind of integer types
// (e.g. typedef char sal_Int8). In this case, we don't need to
// worry about the misinterpretation of char values.
const auto IntTypedef = qualType(
hasDeclaration(typedefDecl(hasAnyListedName(CharTypdefsToIgnoreList))));

const auto SignedCharType = expr(hasType(qualType(
allOf(isAnyCharacter(), isSignedInteger(), unless(IntTypedef)))));

const auto IntegerType = qualType(allOf(isInteger(), unless(isAnyCharacter()),
unless(booleanType())))
.bind("integerType");

// We are interested in signed char -> integer conversion.
const auto ImplicitCastExpr =
implicitCastExpr(hasSourceExpression(SignedCharType),
hasImplicitDestinationType(IntegerType))
.bind("castExpression");

const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));

// We catch any type of casts to an integer. We need to have these cast
// expressions explicitly to catch only those casts which are direct children
// of an assignment/declaration.
const auto CastExpr = expr(anyOf(ImplicitCastExpr, CStyleCastExpr,
StaticCastExpr, FunctionalCastExpr));

// Catch assignments with the suspicious type conversion.
const auto AssignmentOperatorExpr = expr(binaryOperator(
hasOperatorName("="), hasLHS(hasType(IntegerType)), hasRHS(CastExpr)));

Finder->addMatcher(AssignmentOperatorExpr, this);

// Catch declarations with the suspicious type conversion.
const auto Declaration =
varDecl(isDefinition(), hasType(IntegerType), hasInitializer(CastExpr));

Finder->addMatcher(Declaration, this);
}

void SignedCharMisuseCheck::check(const MatchFinder::MatchResult &Result) {
const auto *CastExpression =
Result.Nodes.getNodeAs<ImplicitCastExpr>("castExpression");
const auto *IntegerType = Result.Nodes.getNodeAs<QualType>("integerType");
assert(CastExpression);
assert(IntegerType);

// Ignore the match if we know that the value is not negative.
// The potential misinterpretation happens for negative values only.
Expr::EvalResult EVResult;
if (!CastExpression->isValueDependent() &&
CastExpression->getSubExpr()->EvaluateAsInt(EVResult, *Result.Context)) {
llvm::APSInt Value1 = EVResult.Val.getInt();
if (Value1.isNonNegative())
return;
}

diag(CastExpression->getBeginLoc(),
"'signed char' to %0 conversion; "
"consider casting to 'unsigned char' first.")
<< *IntegerType;
}

} // namespace bugprone
} // namespace tidy
} // namespace clang
44 changes: 44 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===--- SignedCharMisuseCheck.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_BUGPRONE_SIGNEDCHARMISUSECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H

#include "../ClangTidyCheck.h"

namespace clang {
namespace tidy {
namespace bugprone {

/// Finds ``signed char`` -> integer conversions which might indicate a programming
/// error. The basic problem with the ``signed char``, that it might store the
/// non-ASCII characters as negative values. The human programmer probably
/// expects that after an integer conversion the converted value matches with the
/// character code (a value from [0..255]), however, the actual value is in
/// [-128..127] interval. This also applies to the plain ``char`` type on
/// those implementations which represent ``char`` similar to ``signed char``.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-signed-char-misuse.html
class SignedCharMisuseCheck : public ClangTidyCheck {
public:
SignedCharMisuseCheck(StringRef Name, ClangTidyContext *Context);

void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

private:
const std::string CharTypdefsToIgnoreList;
};

} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AST_MATCHER(StringLiteral, containsNul) {

void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
// Match a string that contains embedded NUL character. Extra-checks are
// applied in |check| to find incorectly escaped characters.
// applied in |check| to find incorrectly escaped characters.
Finder->addMatcher(stringLiteral(containsNul()).bind("strlit"), this);

// The remaining checks only apply to C++.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
}

// Iterate over all the fields in a record type, both direct and indirect (e.g.
// if the record contains an anonmyous struct).
// if the record contains an anonymous struct).
template <typename T, typename Func>
void forEachField(const RecordDecl &Record, const T &Fields, Func &&Fn) {
for (const FieldDecl *F : Fields) {
Expand Down Expand Up @@ -424,7 +424,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
}

// Collect all fields in order, both direct fields and indirect fields from
// anonmyous record types.
// anonymous record types.
SmallVector<const FieldDecl *, 16> OrderedFields;
forEachField(ClassDecl, ClassDecl.fields(),
[&](const FieldDecl *F) { OrderedFields.push_back(F); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void SlicingCheck::registerMatchers(MatchFinder *Finder) {
const auto IsWithinDerivedCtor =
hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl"))));

// Assignement slicing: "a = b;" and "a = std::move(b);" variants.
// Assignment slicing: "a = b;" and "a = std::move(b);" variants.
const auto SlicesObjectInAssignment =
callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
isMoveAssignmentOperator()),
Expand Down Expand Up @@ -75,7 +75,7 @@ void SlicingCheck::DiagnoseSlicedOverriddenMethods(
const CXXRecordDecl &BaseDecl) {
if (DerivedDecl.getCanonicalDecl() == BaseDecl.getCanonicalDecl())
return;
for (const auto &Method : DerivedDecl.methods()) {
for (const auto *Method : DerivedDecl.methods()) {
// Virtual destructors are OK. We're ignoring constructors since they are
// tagged as overrides.
if (isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void GlobalNamesInHeadersCheck::check(const MatchFinder::MatchResult &Result) {

if (const auto *UsingDirective = dyn_cast<UsingDirectiveDecl>(D)) {
if (UsingDirective->getNominatedNamespace()->isAnonymousNamespace()) {
// Anynoumous namespaces inject a using directive into the AST to import
// Anonymous namespaces inject a using directive into the AST to import
// the names into the containing namespace.
// We should not have them in headers, but there is another warning for
// that.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/google/IntegerTypesCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace runtime {
/// Finds uses of `short`, `long` and `long long` and suggest replacing them
/// with `u?intXX(_t)?`.
///
/// Correspondig cpplint.py check: 'runtime/int'.
/// Corresponding cpplint.py check: 'runtime/int'.
class IntegerTypesCheck : public ClangTidyCheck {
public:
IntegerTypesCheck(StringRef Name, ClangTidyContext *Context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace tidy {
namespace modernize {

void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) {
// std::array<> is avaliable since C++11.
// std::array<> is available since C++11.
if (!getLangOpts().CPlusPlus11)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ std::string VariableNamer::createIndexName() {
return OldIndex->getName();
}

/// Determines whether or not the the name \a Symbol conflicts with
/// Determines whether or not the name \a Symbol conflicts with
/// language keywords or defined macros. Also checks if the name exists in
/// LoopContext, any of its parent contexts, or any of its child statements.
///
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class DependencyFinderASTVisitor
///
/// In order to avoid this, this class looks at the container expression
/// `arr[k]` and decides whether or not it contains a sub-expression declared
/// within the the loop body.
/// within the loop body.
bool dependsOnInsideVariable(const clang::Stmt *Body) {
DependsOnInsideVariable = false;
TraverseStmt(const_cast<clang::Stmt *>(Body));
Expand Down
Loading

0 comments on commit c2c98c9

Please sign in to comment.