2019-09-23 17:32:07 +08:00
|
|
|
//===- unittest/AST/ASTImporterODRStrategiesTest.cpp -----------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Type-parameterized tests to verify the import behaviour in case of ODR
|
|
|
|
// violation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ASTImporterFixtures.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace ast_matchers {
|
|
|
|
|
|
|
|
using internal::BindableMatcher;
|
|
|
|
|
|
|
|
// DeclTy: Type of the Decl to check.
|
|
|
|
// Prototype: "Prototype" (forward declaration) of the Decl.
|
|
|
|
// Definition: A definition for the Prototype.
|
|
|
|
// ConflictingPrototype: A prototype with the same name but different
|
|
|
|
// declaration.
|
|
|
|
// ConflictingDefinition: A different definition for Prototype.
|
|
|
|
// ConflictingProtoDef: A definition for ConflictingPrototype.
|
|
|
|
// getPattern: Return a matcher that matches any of Prototype, Definition,
|
|
|
|
// ConflictingPrototype, ConflictingDefinition, ConflictingProtoDef.
|
|
|
|
|
|
|
|
struct Function {
|
|
|
|
using DeclTy = FunctionDecl;
|
2019-09-24 13:50:02 +08:00
|
|
|
static constexpr auto *Prototype = "void X(int);";
|
2019-09-23 17:32:07 +08:00
|
|
|
static constexpr auto *ConflictingPrototype = "void X(double);";
|
2019-09-24 13:50:02 +08:00
|
|
|
static constexpr auto *Definition = "void X(int a) {}";
|
2019-09-23 17:32:07 +08:00
|
|
|
static constexpr auto *ConflictingDefinition = "void X(double a) {}";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return functionDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_C99; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Typedef {
|
|
|
|
using DeclTy = TypedefNameDecl;
|
|
|
|
static constexpr auto *Definition = "typedef int X;";
|
|
|
|
static constexpr auto *ConflictingDefinition = "typedef double X;";
|
|
|
|
BindableMatcher<Decl> getPattern() { return typedefNameDecl(hasName("X")); }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TypedefAlias {
|
|
|
|
using DeclTy = TypedefNameDecl;
|
|
|
|
static constexpr auto *Definition = "using X = int;";
|
|
|
|
static constexpr auto *ConflictingDefinition = "using X = double;";
|
|
|
|
BindableMatcher<Decl> getPattern() { return typedefNameDecl(hasName("X")); }
|
Rename APIs in unittests/AST/Language.h in preparation to share them
Summary:
Declaring these helpers in the ast_matcher namespace in the clangAST
unit test seems inappropriate -- neither these helpers, nor clangAST have
anything to do with AST matchers. Therefore, I moved these helpers to
the clang namespace.
Declaring another typedef called "ArgVector" is not a good idea -- we
already have both "ArgVector", "ArgsVector", and "ArgList". I expanded
it into the underlying type.
Declaring another enum called "Language" is not a good idea because we
arleady have the "clang::Language" enum. I renamed it to
"TestLanguage".
Similarly, I renamed "getBasicRunOptionsForLanguage" to
"getCommandLineArgsForTesting" to explain the semantics better (what are
"run options"?) and not repeat types in the function name
("ForLanguage").
Reviewers: shafik, rengolin, sammccall
Reviewed By: sammccall
Subscribers: gribozavr2, sammccall, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80786
2020-05-29 20:12:51 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX11; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Enum {
|
|
|
|
using DeclTy = EnumDecl;
|
|
|
|
static constexpr auto *Definition = "enum X { a, b };";
|
|
|
|
static constexpr auto *ConflictingDefinition = "enum X { a, b, c };";
|
|
|
|
BindableMatcher<Decl> getPattern() { return enumDecl(hasName("X")); }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
struct EnumClass {
|
|
|
|
using DeclTy = EnumDecl;
|
|
|
|
static constexpr auto *Definition = "enum class X { a, b };";
|
|
|
|
static constexpr auto *ConflictingDefinition = "enum class X { a, b, c };";
|
|
|
|
BindableMatcher<Decl> getPattern() { return enumDecl(hasName("X")); }
|
Rename APIs in unittests/AST/Language.h in preparation to share them
Summary:
Declaring these helpers in the ast_matcher namespace in the clangAST
unit test seems inappropriate -- neither these helpers, nor clangAST have
anything to do with AST matchers. Therefore, I moved these helpers to
the clang namespace.
Declaring another typedef called "ArgVector" is not a good idea -- we
already have both "ArgVector", "ArgsVector", and "ArgList". I expanded
it into the underlying type.
Declaring another enum called "Language" is not a good idea because we
arleady have the "clang::Language" enum. I renamed it to
"TestLanguage".
Similarly, I renamed "getBasicRunOptionsForLanguage" to
"getCommandLineArgsForTesting" to explain the semantics better (what are
"run options"?) and not repeat types in the function name
("ForLanguage").
Reviewers: shafik, rengolin, sammccall
Reviewed By: sammccall
Subscribers: gribozavr2, sammccall, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80786
2020-05-29 20:12:51 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX11; }
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
};
|
|
|
|
|
2019-09-23 17:32:07 +08:00
|
|
|
struct EnumConstant {
|
|
|
|
using DeclTy = EnumConstantDecl;
|
|
|
|
static constexpr auto *Definition = "enum E { X = 0 };";
|
|
|
|
static constexpr auto *ConflictingDefinition = "enum E { X = 1 };";
|
|
|
|
BindableMatcher<Decl> getPattern() { return enumConstantDecl(hasName("X")); }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Class {
|
|
|
|
using DeclTy = CXXRecordDecl;
|
|
|
|
static constexpr auto *Prototype = "class X;";
|
|
|
|
static constexpr auto *Definition = "class X {};";
|
|
|
|
static constexpr auto *ConflictingDefinition = "class X { int A; };";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return cxxRecordDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Variable {
|
|
|
|
using DeclTy = VarDecl;
|
|
|
|
static constexpr auto *Prototype = "extern int X;";
|
|
|
|
static constexpr auto *ConflictingPrototype = "extern float X;";
|
|
|
|
static constexpr auto *Definition = "int X;";
|
|
|
|
static constexpr auto *ConflictingDefinition = "float X;";
|
|
|
|
BindableMatcher<Decl> getPattern() { return varDecl(hasName("X")); }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ClassTemplate {
|
|
|
|
using DeclTy = ClassTemplateDecl;
|
|
|
|
static constexpr auto *Prototype = "template <class> class X;";
|
|
|
|
static constexpr auto *ConflictingPrototype = "template <int> class X;";
|
|
|
|
static constexpr auto *Definition = "template <class> class X {};";
|
|
|
|
static constexpr auto *ConflictingDefinition =
|
|
|
|
"template <class> class X { int A; };";
|
|
|
|
static constexpr auto *ConflictingProtoDef = "template <int> class X { };";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return classTemplateDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FunctionTemplate {
|
|
|
|
using DeclTy = FunctionTemplateDecl;
|
|
|
|
static constexpr auto *Definition0 =
|
|
|
|
R"(
|
|
|
|
template <class T>
|
|
|
|
void X(T a) {};
|
|
|
|
)";
|
|
|
|
// This is actually not a conflicting definition, but another primary template.
|
|
|
|
static constexpr auto *Definition1 =
|
|
|
|
R"(
|
|
|
|
template <class T>
|
|
|
|
void X(T* a) {};
|
|
|
|
)";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return functionTemplateDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
|
|
|
static std::string getDef0() { return Definition0; }
|
|
|
|
static std::string getDef1() { return Definition1; }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const internal::VariadicDynCastAllOfMatcher<Decl, VarTemplateDecl>
|
|
|
|
varTemplateDecl;
|
|
|
|
|
|
|
|
struct VarTemplate {
|
|
|
|
using DeclTy = VarTemplateDecl;
|
|
|
|
static constexpr auto *Definition =
|
|
|
|
R"(
|
|
|
|
template <class T>
|
|
|
|
constexpr T X = 0;
|
|
|
|
)";
|
|
|
|
static constexpr auto *ConflictingDefinition =
|
|
|
|
R"(
|
|
|
|
template <int>
|
|
|
|
constexpr int X = 0;
|
|
|
|
)";
|
|
|
|
BindableMatcher<Decl> getPattern() { return varTemplateDecl(hasName("X")); }
|
Rename APIs in unittests/AST/Language.h in preparation to share them
Summary:
Declaring these helpers in the ast_matcher namespace in the clangAST
unit test seems inappropriate -- neither these helpers, nor clangAST have
anything to do with AST matchers. Therefore, I moved these helpers to
the clang namespace.
Declaring another typedef called "ArgVector" is not a good idea -- we
already have both "ArgVector", "ArgsVector", and "ArgList". I expanded
it into the underlying type.
Declaring another enum called "Language" is not a good idea because we
arleady have the "clang::Language" enum. I renamed it to
"TestLanguage".
Similarly, I renamed "getBasicRunOptionsForLanguage" to
"getCommandLineArgsForTesting" to explain the semantics better (what are
"run options"?) and not repeat types in the function name
("ForLanguage").
Reviewers: shafik, rengolin, sammccall
Reviewed By: sammccall
Subscribers: gribozavr2, sammccall, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80786
2020-05-29 20:12:51 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX14; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ClassTemplateSpec {
|
|
|
|
using DeclTy = ClassTemplateSpecializationDecl;
|
|
|
|
static constexpr auto *Prototype =
|
|
|
|
R"(
|
|
|
|
template <class T> class X;
|
|
|
|
template <> class X<int>;
|
|
|
|
)";
|
|
|
|
static constexpr auto *Definition =
|
|
|
|
R"(
|
|
|
|
template <class T> class X;
|
|
|
|
template <> class X<int> {};
|
|
|
|
)";
|
|
|
|
static constexpr auto *ConflictingDefinition =
|
|
|
|
R"(
|
|
|
|
template <class T> class X;
|
|
|
|
template <> class X<int> { int A; };
|
|
|
|
)";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return classTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Function template specializations are all "full" specializations.
|
|
|
|
// Structural equivalency does not check the body of functions, so we cannot
|
|
|
|
// create conflicting function template specializations.
|
|
|
|
struct FunctionTemplateSpec {
|
|
|
|
using DeclTy = FunctionDecl;
|
|
|
|
|
|
|
|
static constexpr auto *Definition0 =
|
|
|
|
R"(
|
|
|
|
template <class T>
|
|
|
|
void X(T a);
|
|
|
|
template <> void X(int a) {};
|
|
|
|
)";
|
|
|
|
|
|
|
|
// This is actually not a conflicting definition, but another full
|
|
|
|
// specialization.
|
|
|
|
// Thus, during the import we would create a new specialization with a
|
|
|
|
// different type argument.
|
|
|
|
static constexpr auto *Definition1 =
|
|
|
|
R"(
|
|
|
|
template <class T>
|
|
|
|
void X(T a);
|
|
|
|
template <> void X(double a) {};
|
|
|
|
)";
|
|
|
|
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return functionDecl(hasName("X"), isExplicitTemplateSpecialization(),
|
|
|
|
unless(isImplicit()));
|
|
|
|
}
|
|
|
|
static std::string getDef0() { return Definition0; }
|
|
|
|
static std::string getDef1() { return Definition1; }
|
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".
I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.
Reviewers: shafik, hlopko
Reviewed By: hlopko
Subscribers: jfb, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 22:10:39 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX03; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const internal::VariadicDynCastAllOfMatcher<
|
|
|
|
Decl, VarTemplateSpecializationDecl>
|
|
|
|
varTemplateSpecializationDecl;
|
|
|
|
|
|
|
|
struct VarTemplateSpec {
|
|
|
|
using DeclTy = VarTemplateSpecializationDecl;
|
|
|
|
static constexpr auto *Definition =
|
|
|
|
R"(
|
|
|
|
template <class T> T X = 0;
|
|
|
|
template <> int X<int> = 0;
|
|
|
|
)";
|
|
|
|
static constexpr auto *ConflictingDefinition =
|
|
|
|
R"(
|
|
|
|
template <class T> T X = 0;
|
|
|
|
template <> float X<int> = 1.0;
|
|
|
|
)";
|
|
|
|
BindableMatcher<Decl> getPattern() {
|
|
|
|
return varTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
|
|
|
|
}
|
Rename APIs in unittests/AST/Language.h in preparation to share them
Summary:
Declaring these helpers in the ast_matcher namespace in the clangAST
unit test seems inappropriate -- neither these helpers, nor clangAST have
anything to do with AST matchers. Therefore, I moved these helpers to
the clang namespace.
Declaring another typedef called "ArgVector" is not a good idea -- we
already have both "ArgVector", "ArgsVector", and "ArgList". I expanded
it into the underlying type.
Declaring another enum called "Language" is not a good idea because we
arleady have the "clang::Language" enum. I renamed it to
"TestLanguage".
Similarly, I renamed "getBasicRunOptionsForLanguage" to
"getCommandLineArgsForTesting" to explain the semantics better (what are
"run options"?) and not repeat types in the function name
("ForLanguage").
Reviewers: shafik, rengolin, sammccall
Reviewed By: sammccall
Subscribers: gribozavr2, sammccall, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80786
2020-05-29 20:12:51 +08:00
|
|
|
TestLanguage getLang() { return Lang_CXX14; }
|
2019-09-23 17:32:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename TypeParam, ASTImporter::ODRHandlingType ODRHandlingParam>
|
|
|
|
struct ODRViolation : ASTImporterOptionSpecificTestBase {
|
|
|
|
|
|
|
|
using DeclTy = typename TypeParam::DeclTy;
|
|
|
|
|
|
|
|
ODRViolation() { ODRHandling = ODRHandlingParam; }
|
|
|
|
|
|
|
|
static std::string getPrototype() { return TypeParam::Prototype; }
|
|
|
|
static std::string getConflictingPrototype() {
|
|
|
|
return TypeParam::ConflictingPrototype;
|
|
|
|
}
|
|
|
|
static std::string getDefinition() { return TypeParam::Definition; }
|
|
|
|
static std::string getConflictingDefinition() {
|
|
|
|
return TypeParam::ConflictingDefinition;
|
|
|
|
}
|
|
|
|
static std::string getConflictingProtoDef() {
|
|
|
|
return TypeParam::ConflictingProtoDef;
|
|
|
|
}
|
|
|
|
static BindableMatcher<Decl> getPattern() { return TypeParam().getPattern(); }
|
Rename APIs in unittests/AST/Language.h in preparation to share them
Summary:
Declaring these helpers in the ast_matcher namespace in the clangAST
unit test seems inappropriate -- neither these helpers, nor clangAST have
anything to do with AST matchers. Therefore, I moved these helpers to
the clang namespace.
Declaring another typedef called "ArgVector" is not a good idea -- we
already have both "ArgVector", "ArgsVector", and "ArgList". I expanded
it into the underlying type.
Declaring another enum called "Language" is not a good idea because we
arleady have the "clang::Language" enum. I renamed it to
"TestLanguage".
Similarly, I renamed "getBasicRunOptionsForLanguage" to
"getCommandLineArgsForTesting" to explain the semantics better (what are
"run options"?) and not repeat types in the function name
("ForLanguage").
Reviewers: shafik, rengolin, sammccall
Reviewed By: sammccall
Subscribers: gribozavr2, sammccall, martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D80786
2020-05-29 20:12:51 +08:00
|
|
|
static TestLanguage getLang() { return TypeParam().getLang(); }
|
2019-09-23 17:32:07 +08:00
|
|
|
|
|
|
|
template <std::string (*ToTUContent)(), std::string (*FromTUContent)(),
|
|
|
|
void (*ResultChecker)(llvm::Expected<Decl *> &, Decl *, Decl *)>
|
|
|
|
void TypedTest_ImportAfter() {
|
|
|
|
Decl *ToTU = getToTuDecl(ToTUContent(), getLang());
|
|
|
|
auto *ToD = FirstDeclMatcher<DeclTy>().match(ToTU, getPattern());
|
|
|
|
|
|
|
|
Decl *FromTU = getTuDecl(FromTUContent(), getLang());
|
|
|
|
auto *FromD = FirstDeclMatcher<DeclTy>().match(FromTU, getPattern());
|
|
|
|
|
|
|
|
auto Result = importOrError(FromD, getLang());
|
|
|
|
|
|
|
|
ResultChecker(Result, ToTU, ToD);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that a Decl has been successfully imported into a standalone redecl
|
|
|
|
// chain.
|
|
|
|
static void CheckImportedAsNew(llvm::Expected<Decl *> &Result, Decl *ToTU,
|
|
|
|
Decl *ToD) {
|
|
|
|
ASSERT_TRUE(isSuccess(Result));
|
|
|
|
Decl *ImportedD = *Result;
|
|
|
|
ASSERT_TRUE(ImportedD);
|
|
|
|
EXPECT_NE(ImportedD, ToD);
|
|
|
|
EXPECT_EQ(DeclCounter<DeclTy>().match(ToTU, getPattern()), 2u);
|
|
|
|
|
|
|
|
// There may be a hidden fwd spec decl before a function spec decl.
|
|
|
|
if (auto *ImportedF = dyn_cast<FunctionDecl>(ImportedD))
|
|
|
|
if (ImportedF->getTemplatedKind() ==
|
|
|
|
FunctionDecl::TK_FunctionTemplateSpecialization)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EXPECT_FALSE(ImportedD->getPreviousDecl());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that a Decl was not imported because of NameConflict.
|
|
|
|
static void CheckImportNameConflict(llvm::Expected<Decl *> &Result,
|
|
|
|
Decl *ToTU, Decl *ToD) {
|
|
|
|
EXPECT_TRUE(isImportError(Result, ImportError::NameConflict));
|
|
|
|
EXPECT_EQ(DeclCounter<DeclTy>().match(ToTU, getPattern()), 1u);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that a Decl was not imported because lookup found the same decl.
|
|
|
|
static void CheckImportFoundExisting(llvm::Expected<Decl *> &Result,
|
|
|
|
Decl *ToTU, Decl *ToD) {
|
|
|
|
ASSERT_TRUE(isSuccess(Result));
|
|
|
|
EXPECT_EQ(DeclCounter<DeclTy>().match(ToTU, getPattern()), 1u);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TypedTest_ImportConflictingDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingDefinition,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingProtoAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getPrototype, getConflictingPrototype,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingProtoAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingPrototype,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingDefAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getConflictingPrototype, getDefinition,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingProtoDefAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getPrototype, getConflictingProtoDef,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingProtoAfterProtoDef() {
|
|
|
|
TypedTest_ImportAfter<getConflictingProtoDef, getPrototype,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingProtoDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingProtoDef,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_ImportConflictingDefAfterProtoDef() {
|
|
|
|
TypedTest_ImportAfter<getConflictingProtoDef, getDefinition,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TypedTest_DontImportConflictingProtoAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getPrototype, getConflictingPrototype,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingDefinition,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingProtoAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingPrototype,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingDefAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getConflictingPrototype, getDefinition,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingProtoDefAfterProto() {
|
|
|
|
TypedTest_ImportAfter<getPrototype, getConflictingProtoDef,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingProtoAfterProtoDef() {
|
|
|
|
TypedTest_ImportAfter<getConflictingProtoDef, getPrototype,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingProtoDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<getDefinition, getConflictingProtoDef,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportConflictingDefAfterProtoDef() {
|
|
|
|
TypedTest_ImportAfter<getConflictingProtoDef, getDefinition,
|
|
|
|
CheckImportNameConflict>();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used for function templates and function template specializations.
|
|
|
|
void TypedTest_ImportDifferentDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<TypeParam::getDef0, TypeParam::getDef1,
|
|
|
|
CheckImportedAsNew>();
|
|
|
|
}
|
|
|
|
void TypedTest_DontImportSameDefAfterDef() {
|
|
|
|
TypedTest_ImportAfter<TypeParam::getDef0, TypeParam::getDef0,
|
|
|
|
CheckImportFoundExisting>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ==============================
|
|
|
|
// Define the parametrized tests.
|
|
|
|
// ==============================
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
#define ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE( \
|
2019-09-23 17:32:07 +08:00
|
|
|
TypeParam, ODRHandlingParam, NamePrefix, TestCase) \
|
|
|
|
using TypeParam##ODRHandlingParam = \
|
|
|
|
ODRViolation<TypeParam, ASTImporter::ODRHandlingType::ODRHandlingParam>; \
|
|
|
|
TEST_P(TypeParam##ODRHandlingParam, NamePrefix##TestCase) { \
|
|
|
|
TypedTest_##TestCase(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Typedef, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
TypedefAlias, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Enum, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
EnumClass, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
EnumConstant, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Class, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
VarTemplate, Liberal, ,
|
|
|
|
ImportConflictingDefAfterDef)
|
|
|
|
// Class and variable template specializations/instantiatons are always
|
|
|
|
// imported conservatively, because the AST holds the specializations in a set,
|
|
|
|
// and the key within the set is a hash calculated from the arguments of the
|
|
|
|
// specialization.
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplateSpec, Liberal, ,
|
|
|
|
DontImportConflictingDefAfterDef) // Don't import !!!
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
VarTemplateSpec, Liberal, ,
|
|
|
|
DontImportConflictingDefAfterDef) // Don't import !!!
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Typedef, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
TypedefAlias, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Enum, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
EnumClass, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
EnumConstant, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Class, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
VarTemplate, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplateSpec, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
VarTemplateSpec, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Liberal, ,
|
|
|
|
ImportConflictingDefAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Liberal, ,
|
|
|
|
ImportConflictingDefAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingDefAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Function, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
Variable, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterProto)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingProtoDefAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingProtoDefAfterProto)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingProtoAfterProtoDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingProtoAfterProtoDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingProtoDefAfterDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingProtoDefAfterDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Liberal, ,
|
|
|
|
ImportConflictingDefAfterProtoDef)
|
|
|
|
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
ClassTemplate, Conservative, ,
|
|
|
|
DontImportConflictingDefAfterProtoDef)
|
|
|
|
|
|
|
|
// FunctionTemplate decls overload with each other. Thus, they are imported
|
|
|
|
// always as a new node, independently from any ODRHandling strategy.
|
|
|
|
//
|
|
|
|
// Function template specializations are "full" specializations. Structural
|
|
|
|
// equivalency does not check the body of functions, so we cannot create
|
|
|
|
// conflicting function template specializations. Thus, ODR handling strategies
|
|
|
|
// has nothing to do with function template specializations. Fully specialized
|
|
|
|
// function templates are imported as new nodes if their template arguments are
|
|
|
|
// different.
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplate, Liberal, ,
|
|
|
|
ImportDifferentDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplateSpec, Liberal, ,
|
|
|
|
ImportDifferentDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplate, Conservative, ,
|
|
|
|
ImportDifferentDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplateSpec, Conservative, ,
|
|
|
|
ImportDifferentDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplate, Liberal, ,
|
|
|
|
DontImportSameDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplateSpec, Liberal, ,
|
|
|
|
DontImportSameDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplate, Conservative, ,
|
|
|
|
DontImportSameDefAfterDef)
|
2021-05-15 01:15:20 +08:00
|
|
|
ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
|
2019-09-23 17:32:07 +08:00
|
|
|
FunctionTemplateSpec, Conservative, ,
|
|
|
|
DontImportSameDefAfterDef)
|
|
|
|
|
|
|
|
// ======================
|
|
|
|
// Instantiate the tests.
|
|
|
|
// ======================
|
|
|
|
|
2019-09-24 17:00:46 +08:00
|
|
|
// FIXME: These fail on Windows.
|
|
|
|
#if !defined(_WIN32)
|
2021-05-15 01:15:20 +08:00
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
2019-09-24 17:00:46 +08:00
|
|
|
#endif
|
2021-05-15 01:15:20 +08:00
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, TypedefConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, TypedefAliasConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, EnumConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
ODRViolationTests, EnumClassConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, EnumConstantConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions );
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, VariableConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassTemplateConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionTemplateConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
2019-09-23 17:32:07 +08:00
|
|
|
// FIXME: Make VarTemplate tests work.
|
2021-05-15 01:15:20 +08:00
|
|
|
//INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
//ODRViolationTests, VarTemplateConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
//DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionTemplateSpecConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassTemplateSpecConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
2019-09-23 17:32:07 +08:00
|
|
|
// FIXME: Make VarTemplateSpec tests work.
|
2021-05-15 01:15:20 +08:00
|
|
|
//INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
//ODRViolationTests, VarTemplateSpecConservative,
|
2021-05-15 01:15:20 +08:00
|
|
|
//DefaultTestValuesForRunOptions);
|
2019-09-23 17:32:07 +08:00
|
|
|
|
2019-09-24 17:00:46 +08:00
|
|
|
// FIXME: These fail on Windows.
|
|
|
|
#if !defined(_WIN32)
|
2021-05-15 01:15:20 +08:00
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
2019-09-24 17:00:46 +08:00
|
|
|
#endif
|
2021-05-15 01:15:20 +08:00
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, TypedefLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, TypedefAliasLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, EnumLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
[ASTImporter] Added visibility check for scoped enums.
Summary:
ASTImporter makes now difference between C++11 scoped enums with same
name in different translation units if these are not visible outside.
Enum declarations are linked into decl chain correctly.
Reviewers: martong, a.sidorin, shafik, a_sidorin, teemperor
Reviewed By: shafik, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74554
2020-02-17 21:25:16 +08:00
|
|
|
ODRViolationTests, EnumClassLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, EnumConstantLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, VariableLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassTemplateLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionTemplateLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
2019-09-23 17:32:07 +08:00
|
|
|
// FIXME: Make VarTemplate tests work.
|
2021-05-15 01:15:20 +08:00
|
|
|
// INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
// ODRViolationTests, VarTemplateLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
// DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, ClassTemplateSpecLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
|
|
|
INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
ODRViolationTests, FunctionTemplateSpecLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
DefaultTestValuesForRunOptions);
|
2019-09-23 17:32:07 +08:00
|
|
|
// FIXME: Make VarTemplateSpec tests work.
|
2021-05-15 01:15:20 +08:00
|
|
|
//INSTANTIATE_TEST_SUITE_P(
|
2019-09-23 17:32:07 +08:00
|
|
|
//ODRViolationTests, VarTemplateSpecLiberal,
|
2021-05-15 01:15:20 +08:00
|
|
|
//DefaultTestValuesForRunOptions );
|
2019-09-23 17:32:07 +08:00
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
} // end namespace ast_matchers
|
|
|
|
} // end namespace clang
|