Skip to content

Commit

Permalink
SWDEV-179954 - OpenCL/LC - Merge branch amd-master into amd-common
Browse files Browse the repository at this point in the history
Change-Id: I0f7cc3b7ac5cbc0404352f3101724d8c52112df7
  • Loading branch information
Jenkins committed Oct 2, 2019
2 parents 2035986 + aef104a commit 45fa31a
Show file tree
Hide file tree
Showing 39 changed files with 257 additions and 165 deletions.
28 changes: 22 additions & 6 deletions docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2288,22 +2288,38 @@ the configuration (without a prefix: ``Auto``).
std::unique_ptr<int[]> foo() {} // Won't be affected

**Standard** (``LanguageStandard``)
Format compatible with this standard, e.g. use ``A<A<int> >``
instead of ``A<A<int>>`` for ``LS_Cpp03``.
.. code-block:: c++

c++03: latest:
vector<set<int> > x; vs. vector<set<int>> x;
Parse and format C++ constructs compatible with this standard.

Possible values:

* ``LS_Cpp03`` (in configuration: ``Cpp03``)
* ``LS_Cpp03`` (in configuration: ``c++03``)
Use C++03-compatible syntax.

* ``LS_Cpp11`` (in configuration: ``Cpp11``)
Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of
``A<A<int> >``).
* ``LS_Cpp11`` (in configuration: ``c++11``)
Use C++11-compatible syntax.

* ``LS_Cpp14`` (in configuration: ``c++14``)
Use C++14-compatible syntax.

* ``LS_Cpp17`` (in configuration: ``c++17``)
Use C++17-compatible syntax.

* ``LS_Cpp20`` (in configuration: ``c++20``)
Use C++20-compatible syntax.

* ``LS_Latest`` (in configuration: ``Latest``)
Parse and format using the latest supported language version.

* ``LS_Auto`` (in configuration: ``Auto``)
Automatic detection based on the input.

* ``Cpp03``: deprecated alias for ``c++03``

* ``Cpp11``: deprecated alias for ``Latest``

**StatementMacros** (``std::vector<std::string>``)
A vector of macros that should be interpreted as complete
Expand Down
10 changes: 9 additions & 1 deletion docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,15 @@ AST Matchers
clang-format
------------

- ...
- The ``Standard`` style option specifies which version of C++ should be used
when parsing and formatting C++ code. The set of allowed values has changed:
- ``Latest`` will always enable new C++ language features.
- ``c++03``, ``c++11``, ``c++14``, ``c++17``, ``c++20`` will pin to exactly
that language version.
- ``Auto`` is the default and detects style from the code (this is unchanged).
The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that
``Cpp11`` is treated as ``Latest``, as this was always clang-format's behavior.
(One motivation for this change is the new name describes the behavior better).

libclang
--------
Expand Down
2 changes: 1 addition & 1 deletion include/clang/AST/ASTFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Stmt;
#include "clang/AST/StmtNodes.inc"
class Type;
#define TYPE(DERIVED, BASE) class DERIVED##Type;
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
class CXXCtorInitializer;

} // end namespace clang
Expand Down
4 changes: 2 additions & 2 deletions include/clang/AST/ASTTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ASTNodeKind {
#include "clang/AST/StmtNodes.inc"
NKI_Type,
#define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
NKI_OMPClause,
#define OPENMP_CLAUSE(TextualSpelling, Class) NKI_##Class,
#include "clang/Basic/OpenMPKinds.def"
Expand Down Expand Up @@ -205,7 +205,7 @@ KIND_TO_KIND_ID(OMPClause)
#define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
#include "clang/AST/StmtNodes.inc"
#define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
#define OPENMP_CLAUSE(TextualSpelling, Class) KIND_TO_KIND_ID(Class)
#include "clang/Basic/OpenMPKinds.def"
#undef KIND_TO_KIND_ID
Expand Down
2 changes: 1 addition & 1 deletion include/clang/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ clang_tablegen(DeclNodes.inc -gen-clang-decl-nodes
SOURCE ../Basic/DeclNodes.td
TARGET ClangDeclNodes)

clang_tablegen(TypeNodes.def -gen-clang-type-nodes
clang_tablegen(TypeNodes.inc -gen-clang-type-nodes
SOURCE ../Basic/TypeNodes.td
TARGET ClangTypeNodes)

Expand Down
10 changes: 5 additions & 5 deletions include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ template <typename Derived> class RecursiveASTVisitor {
// Declare Traverse*() for all concrete Type classes.
#define ABSTRACT_TYPE(CLASS, BASE)
#define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
// The above header #undefs ABSTRACT_TYPE and TYPE upon exit.

// Define WalkUpFrom*() and empty Visit*() for all Type classes.
Expand All @@ -444,7 +444,7 @@ template <typename Derived> class RecursiveASTVisitor {
return true; \
} \
bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

// ---- Methods on TypeLocs ----
// FIXME: this currently just calls the matching Type methods
Expand All @@ -460,7 +460,7 @@ template <typename Derived> class RecursiveASTVisitor {
bool VisitTypeLoc(TypeLoc TL) { return true; }

// QualifiedTypeLoc and UnqualTypeLoc are not declared in
// TypeNodes.def and thus need to be handled specially.
// TypeNodes.inc and thus need to be handled specially.
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL) {
return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
}
Expand All @@ -478,7 +478,7 @@ template <typename Derived> class RecursiveASTVisitor {
return true; \
} \
bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

// ---- Methods on Decls ----

Expand Down Expand Up @@ -676,7 +676,7 @@ bool RecursiveASTVisitor<Derived>::TraverseType(QualType T) {
#define TYPE(CLASS, BASE) \
case Type::CLASS: \
DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
}

return true;
Expand Down
6 changes: 3 additions & 3 deletions include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ using CanQualType = CanQual<Type>;

// Provide forward declarations for all of the *Type classes.
#define TYPE(Class, Base) class Class##Type;
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

/// The collection of all-type qualifiers we support.
/// Clang supports five independent qualifiers:
Expand Down Expand Up @@ -1439,7 +1439,7 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
#define TYPE(Class, Base) Class,
#define LAST_TYPE(Class) TypeLast = Class
#define ABSTRACT_TYPE(Class, Base)
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
};

private:
Expand Down Expand Up @@ -2419,7 +2419,7 @@ template <> inline const Class##Type *Type::getAs() const { \
template <> inline const Class##Type *Type::castAs() const { \
return cast<Class##Type>(CanonicalType); \
}
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

/// This class is used for builtin types like 'int'. Builtin
/// types are always canonical and have a literal name field.
Expand Down
2 changes: 1 addition & 1 deletion include/clang/AST/TypeLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TypeLoc {
#define ABSTRACT_TYPE(Class, Base)
#define TYPE(Class, Base) \
Class = Type::Class,
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
Qualified
};

Expand Down
2 changes: 1 addition & 1 deletion include/clang/AST/TypeLocNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
TYPELOC(Qualified, TypeLoc)
#define TYPE(Class, Base) UNQUAL_TYPELOC(Class, Base##Loc)
#define ABSTRACT_TYPE(Class, Base) ABSTRACT_TYPELOC(Class, Base##Loc)
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

#undef DECLARATOR_TYPELOC
#undef TYPESPEC_TYPELOC
Expand Down
4 changes: 2 additions & 2 deletions include/clang/AST/TypeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TypeVisitor {
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) case Type::CLASS: DISPATCH(CLASS##Type);
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"
}
llvm_unreachable("Unknown type class!");
}
Expand All @@ -80,7 +80,7 @@ class TypeVisitor {
#define TYPE(CLASS, PARENT) RetTy Visit##CLASS##Type(const CLASS##Type *T) { \
DISPATCH(PARENT); \
}
#include "clang/AST/TypeNodes.def"
#include "clang/AST/TypeNodes.inc"

/// Method called if \c ImpClass doesn't provide specific handler
/// for some type class.
Expand Down
29 changes: 23 additions & 6 deletions include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1945,15 +1945,32 @@ struct FormatStyle {
/// \endcode
bool SpacesInSquareBrackets;

/// Supported language standards.
/// Supported language standards for parsing and formatting C++ constructs.
/// \code
/// Latest: vector<set<int>>
/// c++03 vs. vector<set<int> >
/// \endcode
///
/// The correct way to spell a specific language version is e.g. ``c++11``.
/// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
enum LanguageStandard {
/// Use C++03-compatible syntax.
/// c++03: Parse and format as C++03.
LS_Cpp03,
/// Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of
/// ``A<A<int> >``).
/// c++11: Parse and format as C++11.
LS_Cpp11,
/// Automatic detection based on the input.
LS_Auto
/// c++14: Parse and format as C++14.
LS_Cpp14,
/// c++17: Parse and format as C++17.
LS_Cpp17,
/// c++20: Parse and format as C++20.
LS_Cpp20,
/// Latest: Parse and format using the latest supported language version.
/// 'Cpp11' is an alias for LS_Latest for historical reasons.
LS_Latest,

/// Auto: Automatic detection based on the input.
/// Parse using the latest language version. Format based on detected input.
LS_Auto,
};

/// Format compatible with this standard, e.g. use ``A<A<int> >``
Expand Down
12 changes: 11 additions & 1 deletion include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,17 @@ class RecursiveSymbolVisitor
TypeBeginLoc, TypeEndLoc))
return false;
}
return visit(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc);
if (const Type *TP = Loc.getTypePtr()) {
if (TP->getTypeClass() == clang::Type::Record)
return visit(TP->getAsCXXRecordDecl(), TypeBeginLoc, TypeEndLoc);
}
return true;
}

bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
const SourceLocation TypeEndLoc =
Lexer::getLocForEndOfToken(TL.getBeginLoc(), 0, SM, LangOpts);
return visit(TL.getTypedefNameDecl(), TL.getBeginLoc(), TypeEndLoc);
}

bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/APValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void APValue::printPretty(raw_ostream &Out, const ASTContext &Ctx,
return;
case APValue::Vector: {
Out << '{';
QualType ElemTy = Ty->getAs<VectorType>()->getElementType();
QualType ElemTy = Ty->castAs<VectorType>()->getElementType();
getVectorElt(0).printPretty(Out, Ctx, ElemTy);
for (unsigned i = 1; i != getVectorLength(); ++i) {
Out << ", ";
Expand Down
Loading

0 comments on commit 45fa31a

Please sign in to comment.