Skip to content

Commit

Permalink
Merged master:2cdf108d329 into amd-gfx:c51048ebf06
Browse files Browse the repository at this point in the history
Local branch amd-gfx c51048e [AMDGPU] Fix discard to demote conversion
Remote branch master 2cdf108 [lldb/DWARF] Add a utility function for (forceful) completion of types
  • Loading branch information
Sw authored and Sw committed Jul 7, 2020
2 parents c51048e + 2cdf108 commit f19d086
Show file tree
Hide file tree
Showing 570 changed files with 13,906 additions and 6,618 deletions.
6 changes: 6 additions & 0 deletions clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "../readability/ElseAfterReturnCheck.h"
#include "../readability/NamespaceCommentCheck.h"
#include "../readability/QualifiedAutoCheck.h"
#include "HeaderGuardCheck.h"
Expand All @@ -24,6 +25,8 @@ namespace llvm_check {
class LLVMModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<readability::ElseAfterReturnCheck>(
"llvm-else-after-return");
CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
Expand All @@ -40,6 +43,9 @@ class LLVMModule : public ClangTidyModule {
ClangTidyOptions getModuleOptions() override {
ClangTidyOptions Options;
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
"0";
return Options;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void ForLoopIndexUseVisitor::addUsage(const Usage &U) {
/// int k = *i + 2;
/// }
/// \endcode
bool ForLoopIndexUseVisitor::TraverseUnaryDeref(UnaryOperator *Uop) {
bool ForLoopIndexUseVisitor::TraverseUnaryOperator(UnaryOperator *Uop) {
// If we dereference an iterator that's actually a pointer, count the
// occurrence.
if (isDereferenceOfUop(Uop, IndexVar)) {
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 @@ -346,7 +346,7 @@ class ForLoopIndexUseVisitor
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
Expr *Init);
bool TraverseMemberExpr(MemberExpr *Member);
bool TraverseUnaryDeref(UnaryOperator *Uop);
bool TraverseUnaryOperator(UnaryOperator *Uop);
bool VisitDeclRefExpr(DeclRefExpr *E);
bool VisitDeclStmt(DeclStmt *S);
bool TraverseStmt(Stmt *S);
Expand Down
9 changes: 5 additions & 4 deletions clang-tools-extra/clangd/Hover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,10 @@ bool isHardLineBreakAfter(llvm::StringRef Line, llvm::StringRef Rest) {
}

void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
const auto &Ctx = ND.getASTContext();
if (ND.isInvalidDecl())
return;

const auto &Ctx = ND.getASTContext();
if (auto *RD = llvm::dyn_cast<RecordDecl>(&ND)) {
if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
HI.Size = Size->getQuantity();
Expand All @@ -671,11 +673,10 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
const auto *Record = FD->getParent();
if (Record)
Record = Record->getDefinition();
if (Record && !Record->isDependentType()) {
if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) {
HI.Offset = Ctx.getFieldOffset(FD) / 8;
if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
HI.Size = Size->getQuantity();
if (!FD->isInvalidDecl())
HI.Offset = Ctx.getFieldOffset(FD) / 8;
}
return;
}
Expand Down
17 changes: 15 additions & 2 deletions clang-tools-extra/clangd/unittests/HoverTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,24 @@ class Foo {})cpp";
HI.NamespaceScope = "";
HI.Definition = "int xx";
HI.LocalScope = "Foo::";
HI.Size = 4;
HI.Type = "int";
HI.AccessSpecifier = "public";
}},
};
{R"cpp(
// error-ok
struct Foo {
Bar xx;
int [[y^y]];
};)cpp",
[](HoverInfo &HI) {
HI.Name = "yy";
HI.Kind = index::SymbolKind::Field;
HI.NamespaceScope = "";
HI.Definition = "int yy";
HI.LocalScope = "Foo::";
HI.Type = "int";
HI.AccessSpecifier = "public";
}}};
for (const auto &Case : Cases) {
SCOPED_TRACE(Case.Code);

Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ New check aliases
:doc:`bugprone-signed-char-misuse
<clang-tidy/checks/bugprone-signed-char-misuse>` was added.

- New alias :doc:`llvm-else-after-return
<clang-tidy/checks/llvm-else-after-return>` to
:doc:`readability-else-after-return
<clang-tidy/checks/readability-else-after-return>` was added.

Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/docs/clang-tidy/checks/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,5 @@ Clang-Tidy Checks
`hicpp-use-nullptr <hicpp-use-nullptr.html>`_, `modernize-use-nullptr <modernize-use-nullptr.html>`_, "Yes"
`hicpp-use-override <hicpp-use-override.html>`_, `modernize-use-override <modernize-use-override.html>`_, "Yes"
`hicpp-vararg <hicpp-vararg.html>`_, `cppcoreguidelines-pro-type-vararg <cppcoreguidelines-pro-type-vararg.html>`_,
`llvm-else-after-return <llvm-else-after-return.html>`_, `readability-else-after-return <readability-else-after-return.html>`_, "Yes"
`llvm-qualified-auto <llvm-qualified-auto.html>`_, `readability-qualified-auto <readability-qualified-auto.html>`_, "Yes"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. title:: clang-tidy - llvm-else-after-return
.. meta::
:http-equiv=refresh: 5;URL=readability-else-after-return.html

llvm-else-after-return
======================

The llvm-else-after-return check is an alias, please see
`readability-else-after-return <readability-else-after-return.html>`_
for more information.

Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ Options
the ``if`` statement is the last statement in its parents scope.
Default value is `true`.


LLVM alias
----------

There is an alias of this check called llvm-else-after-return.
In that version the options :option:`WarnOnUnfixable` and
:option:`WarnOnConditionVariables` are both set to `false` by default.

This check helps to enforce this `LLVM Coding Standards recommendation
<https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return>`_.
6 changes: 6 additions & 0 deletions clang/docs/ClangCommandLineReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,12 @@ X86

.. option:: -maes, -mno-aes

.. option:: -mamx-bf16, -mno-amx-bf16

.. option:: -mamx-int8, -mno-amx-int8

.. option:: -mamx-tile, -mno-amx-tile

.. option:: -mavx, -mno-avx

.. option:: -mavx2, -mno-avx2
Expand Down
28 changes: 28 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,34 @@ These are major API changes that have happened since the 10.0.0 release of
Clang. If upgrading an external codebase that uses Clang as a library,
this section should help get you past the largest hurdles of upgrading.

- ``RecursiveASTVisitor`` no longer calls separate methods to visit specific
operator kinds. Previously, ``RecursiveASTVisitor`` treated unary, binary,
and compound assignment operators as if they were subclasses of the
corresponding AST node. For example, the binary operator plus was treated as
if it was a ``BinAdd`` subclass of the ``BinaryOperator`` class: during AST
traversal of a ``BinaryOperator`` AST node that had a ``BO_Add`` opcode,
``RecursiveASTVisitor`` was calling the ``TraverseBinAdd`` method instead of
``TraverseBinaryOperator``. This feature was contributing a non-trivial
amount of complexity to the implementation of ``RecursiveASTVisitor``, it was
used only in a minor way in Clang, was not tested, and as a result it was
buggy. Furthermore, this feature was creating a non-uniformity in the API.
Since this feature was not documented, it was quite difficult to figure out
how to use ``RecursiveASTVisitor`` to visit operators.

To update your code to the new uniform API, move the code from separate
visitation methods into methods that correspond to the actual AST node and
perform case analysis based on the operator opcode as needed:

* ``TraverseUnary*() => TraverseUnaryOperator()``
* ``WalkUpFromUnary*() => WalkUpFromUnaryOperator()``
* ``VisitUnary*() => VisiUnaryOperator()``
* ``TraverseBin*() => TraverseBinaryOperator()``
* ``WalkUpFromBin*() => WalkUpFromBinaryOperator()``
* ``VisitBin*() => VisiBinaryOperator()``
* ``TraverseBin*Assign() => TraverseCompoundAssignOperator()``
* ``WalkUpFromBin*Assign() => WalkUpFromCompoundAssignOperator()``
* ``VisitBin*Assign() => VisiCompoundAssignOperator()``

Build System Changes
--------------------

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/APValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class APValue {
bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; }

void dump() const;
void dump(raw_ostream &OS, const ASTContext *Context) const;
void dump(raw_ostream &OS, const ASTContext &Context) const;

void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const;
std::string getAsString(const ASTContext &Ctx, QualType Ty) const;
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/AST/ASTNodeTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
#include "clang/AST/LocInfoType.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TemplateArgumentVisitor.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeVisitor.h"

namespace clang {

class APValue;

/**
ASTNodeTraverser traverses the Clang AST for dumping purposes.
Expand All @@ -50,6 +53,7 @@ struct {
void Visit(const OMPClause *C);
void Visit(const BlockDecl::Capture &C);
void Visit(const GenericSelectionExpr::ConstAssociation &A);
void Visit(const APValue &Value, QualType Ty);
};
*/
template <typename Derived, typename NodeDelegateType>
Expand Down Expand Up @@ -211,6 +215,10 @@ class ASTNodeTraverser
});
}

void Visit(const APValue &Value, QualType Ty) {
getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); });
}

void Visit(const comments::Comment *C, const comments::FullComment *FC) {
getNodeDelegate().AddChild([=] {
getNodeDelegate().Visit(C, FC);
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/AST/JSONNodeDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
#include "clang/AST/CommentVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/Type.h"
#include "llvm/Support/JSON.h"

namespace clang {

class APValue;

class NodeStreamer {
bool FirstChild = true;
bool TopLevel = true;
Expand Down Expand Up @@ -201,6 +204,7 @@ class JSONNodeDumper
void Visit(const OMPClause *C);
void Visit(const BlockDecl::Capture &C);
void Visit(const GenericSelectionExpr::ConstAssociation &A);
void Visit(const APValue &Value, QualType Ty);

void VisitTypedefType(const TypedefType *TT);
void VisitFunctionType(const FunctionType *T);
Expand Down
Loading

0 comments on commit f19d086

Please sign in to comment.