[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 06:15:09 PDT 2019


balazske added inline comments.


================
Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:36
+  static constexpr auto *Definition = "void X(int a) {}";
+  static constexpr auto *ConflictingDefinition = "void X(double a) {}";
+  BindableMatcher<Decl> getPattern() {
----------------
Probably for (non-member?) functions there is no possibility for conflicting definition (for same prototype)? This can be the case if the function body is different but this is not checked now. For functions no name conflict happens because of overload, at least if C++ is used. I think the tests here with functions are not needed or only for C language. (Do all these pass?)


================
Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:128
+};
+
+struct ClassTemplateSpec {
----------------
Is this better?
```
struct VariableTemplate {
  using DeclTy = VarTemplateDecl;
  static constexpr auto *Prototype = "template <class T> extern T X;";
  static constexpr auto *ConflictingPrototype =
      "template <class T> extern float X;";
  static constexpr auto *Definition =
      R"(
      template <class T> T X;
      template <> int X<int>;
      )";
  static constexpr auto *ConflictingDefinition =
      R"(
      template <class T> T X;
      template <> float X<int>;
      )";
  static constexpr auto *ConflictingProtoDef =
      R"(
      template <class T> float X;
      template <> float X<int>;
      )";
  // There is no matcher for varTemplateDecl so use a work-around.
  BindableMatcher<Decl> getPattern() {
    return namedDecl(hasName("X"), unless(isImplicit()),
                     has(templateTypeParmDecl()));
  }
};
```


================
Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:151
+};
+
+template <typename TypeParam, ASTImporter::ODRHandlingType ODRHandlingParam>
----------------
`FunctionTemplate` and `FunctionTemplateSpec` are missing?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66951/new/

https://reviews.llvm.org/D66951





More information about the cfe-commits mailing list