Skip to content

Commit

Permalink
Merged master:8304781cae9 into amd-gfx:c64ea0409b2
Browse files Browse the repository at this point in the history
Local branch amd-gfx c64ea04 Merged master:c7c05b0c8a0 into amd-gfx:f946f65516c
Remote branch master 8304781 Add missing strict_fp_to_int
  • Loading branch information
Sw authored and Sw committed Dec 25, 2019
2 parents c64ea04 + 8304781 commit 8f52c0e
Show file tree
Hide file tree
Showing 2,112 changed files with 235,442 additions and 4,436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ findConstToRemove(const FunctionDecl *Def,
if (FileRange.isInvalid())
return None;

return utils::lexer::getConstQualifyingToken(FileRange, *Result.Context,
*Result.SourceManager);
return utils::lexer::getQualifyingToken(
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
}

namespace {
Expand Down
18 changes: 15 additions & 3 deletions clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static bool isUsedToInitializeAConstant(const MatchFinder::MatchResult &Result,
return AsDecl->isImplicit();
}

if (Node.get<EnumConstantDecl>() != nullptr)
if (Node.get<EnumConstantDecl>())
return true;

return llvm::any_of(Result.Context->getParents(Node),
Expand Down Expand Up @@ -125,8 +125,20 @@ bool MagicNumbersCheck::isConstant(const MatchFinder::MatchResult &Result,
if (isUsedToInitializeAConstant(Result, Parent))
return true;

// Ignore this instance, because this match reports the location
// where the template is defined, not where it is instantiated.
// Ignore this instance, because this matches an
// expanded class enumeration value.
if (Parent.get<CStyleCastExpr>() &&
llvm::any_of(
Result.Context->getParents(Parent),
[](const DynTypedNode &GrandParent) {
return GrandParent.get<SubstNonTypeTemplateParmExpr>() !=
nullptr;
}))
return true;

// Ignore this instance, because this match reports the
// location where the template is defined, not where it
// is instantiated.
if (Parent.get<SubstNonTypeTemplateParmExpr>())
return true;

Expand Down
33 changes: 22 additions & 11 deletions clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,20 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range,
return false;
}

llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
const ASTContext &Context,
const SourceManager &SM) {
llvm::Optional<Token> getQualifyingToken(tok::TokenKind TK,
CharSourceRange Range,
const ASTContext &Context,
const SourceManager &SM) {
assert((TK == tok::kw_const || TK == tok::kw_volatile ||
TK == tok::kw_restrict) &&
"TK is not a qualifier keyword");
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Range.getBegin());
StringRef File = SM.getBufferData(LocInfo.first);
Lexer RawLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(),
File.begin(), File.data() + LocInfo.second, File.end());
llvm::Optional<Token> FirstConstTok;
Token LastTokInRange;
llvm::Optional<Token> LastMatchBeforeTemplate;
llvm::Optional<Token> LastMatchAfterTemplate;
bool SawTemplate = false;
Token Tok;
while (!RawLexer.LexFromRawLexer(Tok) &&
Range.getEnd() != Tok.getLocation() &&
Expand All @@ -121,13 +126,19 @@ llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
Tok.setIdentifierInfo(&Info);
Tok.setKind(Info.getTokenID());
}
if (Tok.is(tok::kw_const) && !FirstConstTok)
FirstConstTok = Tok;
LastTokInRange = Tok;
if (Tok.is(tok::less))
SawTemplate = true;
else if (Tok.isOneOf(tok::greater, tok::greatergreater))
LastMatchAfterTemplate = None;
else if (Tok.is(TK)) {
if (SawTemplate)
LastMatchAfterTemplate = Tok;
else
LastMatchBeforeTemplate = Tok;
}
}
// If the last token in the range is a `const`, then it const qualifies the
// type. Otherwise, the first `const` token, if any, is the qualifier.
return LastTokInRange.is(tok::kw_const) ? LastTokInRange : FirstConstTok;
return LastMatchAfterTemplate != None ? LastMatchAfterTemplate
: LastMatchBeforeTemplate;
}
} // namespace lexer
} // namespace utils
Expand Down
14 changes: 8 additions & 6 deletions clang-tools-extra/clang-tidy/utils/LexerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ bool rangeContainsExpansionsOrDirectives(SourceRange Range,
const SourceManager &SM,
const LangOptions &LangOpts);

/// Assuming that ``Range`` spans a const-qualified type, returns the ``const``
/// token in ``Range`` that is responsible for const qualification. ``Range``
/// must be valid with respect to ``SM``. Returns ``None`` if no ``const``
/// 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.
llvm::Optional<Token> getConstQualifyingToken(CharSourceRange Range,
const ASTContext &Context,
const SourceManager &SM);
/// \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
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ Improvements to clang-tidy
The check now supports the ``IgnoreBitFieldsWidths`` option to suppress
the warning for numbers used to specify bit field widths.

The check was updated to eliminate some false positives (such as using
class enumeration as non-type template parameters, or the synthetically
computed lengh of a static user string literal.)

- New :doc:`readability-make-member-function-const
<clang-tidy/checks/readability-make-member-function-const>` check.

Expand Down
8 changes: 5 additions & 3 deletions clang-tools-extra/docs/clang-doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Clang-Doc
.. toctree::
:maxdepth: 1

:program:`clang-doc` is a tool for generating C and C++ documentation from
source code and comments.
:program:`clang-doc` is a tool for generating C and C++ documentation from
source code and comments.

The tool is in a very early development stage, so you might encounter bugs and
crashes. Submitting reports with information about how to reproduce the issue
Expand All @@ -21,7 +21,7 @@ Use

:program:`clang-doc` is a `LibTooling
<https://clang.llvm.org/docs/LibTooling.html>`_-based tool, and so requires a
compile command database for your project (for an example of how to do this
compile command database for your project (for an example of how to do this
see `How To Setup Tooling For LLVM
<https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html>`_).

Expand Down Expand Up @@ -81,7 +81,9 @@ Options
--doxygen - Use only doxygen-style comments to generate docs.
--extra-arg=<string> - Additional argument to append to the compiler command line
Can be used several times.
--extra-arg-before=<string> - Additional argument to prepend to the compiler command line
Can be used several times.
--format=<value> - Format for outputted docs.
=yaml - Documentation in YAML format.
=md - Documentation in MD format.
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/docs/clang-rename.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ That way you can avoid spelling out all the names as command line arguments:
-export-fixes=<filename> - YAML file to store suggested fixes in.
-extra-arg=<string> - Additional argument to append to the compiler command line
Can be used several times.
-extra-arg-before=<string> - Additional argument to prepend to the compiler command line
Can be used several times.
-force - Ignore nonexistent qualified names.
-i - Overwrite edited <file>s.
-input=<string> - YAML file to load oldname-newname pairs from.
Expand Down
Loading

0 comments on commit 8f52c0e

Please sign in to comment.