Skip to content

Commit

Permalink
Merged master:3097427f93dd into amd-gfx:aacb97b51eb5
Browse files Browse the repository at this point in the history
Local branch amd-gfx aacb97b Revert "[AMDGPU] Fix offset for REL32_HI relocs"
Remote branch master 3097427 [obj2yaml] Add support for dumping the .debug_str section.
  • Loading branch information
Sw authored and Sw committed Sep 7, 2020
2 parents aacb97b + 3097427 commit 6c5d93e
Show file tree
Hide file tree
Showing 92 changed files with 2,053 additions and 791 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {

// Drill down to the as-written initializer.
const Expr *E = (*Construct->arg_begin())->IgnoreParenImpCasts();
if (E != E->IgnoreConversionOperator()) {
if (E != E->IgnoreConversionOperatorSingleStep()) {
// We hit a conversion operator. Early-out now as they imply an implicit
// conversion from a different type. Could also mean an explicit
// conversion from the same type but that's pretty rare.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ std::string compareExpressionToZero(const MatchFinder::MatchResult &Result,

std::string replacementExpression(const MatchFinder::MatchResult &Result,
bool Negated, const Expr *E) {
E = E->ignoreParenBaseCasts();
E = E->IgnoreParenBaseCasts();
if (const auto *EC = dyn_cast<ExprWithCleanups>(E))
E = EC->getSubExpr();

Expand Down
17 changes: 17 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,24 @@ the configuration (without a prefix: ``Auto``).
int bbbbbbbbbbbbbbbbbbbbb) {
}

**AttributeMacros** (``std::vector<std::string>``)
A vector of strings that should be interpreted as attributes/qualifiers
instead of identifiers. This can be useful for language extensions or
static analyzer annotations:

.. code-block:: c++

x = (char *__capability)&y;
int function(void) __ununsed;
void only_writes_to_buffer(char *__output buffer);
In the .clang-format configuration file, this can be configured like:

.. code-block:: yaml
AttributeMacros: ['__capability', '__output', '__ununsed']
For example: __capability.

**BinPackArguments** (``bool``)
If ``false``, a function call's arguments will either be all on the
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/Attribute/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)

if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
target_link_libraries(Attribute ${cmake_2_8_12_PRIVATE}
target_link_libraries(Attribute PRIVATE
clangAST
clangBasic
clangFrontend
Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,9 @@ class Expr : public ValueStmt {

/// Skip conversion operators. If this Expr is a call to a conversion
/// operator, return the argument.
Expr *IgnoreConversionOperator() LLVM_READONLY;
const Expr *IgnoreConversionOperator() const {
return const_cast<Expr *>(this)->IgnoreConversionOperator();
Expr *IgnoreConversionOperatorSingleStep() LLVM_READONLY;
const Expr *IgnoreConversionOperatorSingleStep() const {
return const_cast<Expr *>(this)->IgnoreConversionOperatorSingleStep();
}

/// Skip past any parentheses and lvalue casts which might surround this
Expand Down Expand Up @@ -901,9 +901,9 @@ class Expr : public ValueStmt {
/// * What IgnoreParens() skips
/// * CastExpr which represent a derived-to-base cast (CK_DerivedToBase,
/// CK_UncheckedDerivedToBase and CK_NoOp)
Expr *ignoreParenBaseCasts() LLVM_READONLY;
const Expr *ignoreParenBaseCasts() const {
return const_cast<Expr *>(this)->ignoreParenBaseCasts();
Expr *IgnoreParenBaseCasts() LLVM_READONLY;
const Expr *IgnoreParenBaseCasts() const {
return const_cast<Expr *>(this)->IgnoreParenBaseCasts();
}

/// Determine whether this expression is a default function argument.
Expand Down
61 changes: 61 additions & 0 deletions clang/include/clang/AST/IgnoreExpr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===--- IgnoreExpr.h - Ignore intermediate Expressions -----------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file defines common functions to ignore intermediate expression nodes
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_AST_IGNOREEXPR_H
#define LLVM_CLANG_AST_IGNOREEXPR_H

#include "clang/AST/Expr.h"

namespace clang {
namespace detail {
/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
/// Return Fn_n(...(Fn_1(E)))
inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; };
template <typename FnTy, typename... FnTys>
Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
}
} // namespace detail

/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
/// Recursively apply each of the functions to E until reaching a fixed point.
/// Note that a null E is valid; in this case nothing is done.
template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
Expr *LastE = nullptr;
while (E != LastE) {
LastE = E;
E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
}
return E;
}

Expr *IgnoreImplicitCastsSingleStep(Expr *E);

Expr *IgnoreImplicitCastsExtraSingleStep(Expr *E);

Expr *IgnoreCastsSingleStep(Expr *E);

Expr *IgnoreLValueCastsSingleStep(Expr *E);

Expr *IgnoreBaseCastsSingleStep(Expr *E);

Expr *IgnoreImplicitSingleStep(Expr *E);

Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E);

Expr *IgnoreParensOnlySingleStep(Expr *E);

Expr *IgnoreParensSingleStep(Expr *E);

} // namespace clang

#endif // LLVM_CLANG_AST_IGNOREEXPR_H
19 changes: 19 additions & 0 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,24 @@ struct FormatStyle {
/// The template declaration breaking style to use.
BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;

/// A vector of strings that should be interpreted as attributes/qualifiers
/// instead of identifiers. This can be useful for language extensions or
/// static analyzer annotations.
///
/// For example:
/// \code
/// x = (char *__capability)&y;
/// int function(void) __ununsed;
/// void only_writes_to_buffer(char *__output buffer);
/// \endcode
///
/// In the .clang-format configuration file, this can be configured like:
/// \code{.yaml}
/// AttributeMacros: ['__capability', '__output', '__ununsed']
/// \endcode
///
std::vector<std::string> AttributeMacros;

/// If ``false``, a function call's arguments will either be all on the
/// same line or will have one line each.
/// \code
Expand Down Expand Up @@ -2351,6 +2369,7 @@ struct FormatStyle {
R.AlwaysBreakBeforeMultilineStrings &&
AlwaysBreakTemplateDeclarations ==
R.AlwaysBreakTemplateDeclarations &&
AttributeMacros == R.AttributeMacros &&
BinPackArguments == R.BinPackArguments &&
BinPackParameters == R.BinPackParameters &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ add_clang_library(clangAST
ExternalASTMerger.cpp
ExternalASTSource.cpp
FormatString.cpp
IgnoreExpr.cpp
InheritViz.cpp
Interp/ByteCodeEmitter.cpp
Interp/ByteCodeExprGen.cpp
Expand Down
Loading

0 comments on commit 6c5d93e

Please sign in to comment.