Skip to content

Instantly share code, notes, and snippets.

@vsapsai
Created May 5, 2014 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsapsai/44d46dfac05cc2494790 to your computer and use it in GitHub Desktop.
Save vsapsai/44d46dfac05cc2494790 to your computer and use it in GitHub Desktop.
"extern template" test case.
// extern_template.h, .cc don't correspond to interface/implementation pattern.
// They have the same name so that IWYU prints recommendations for both files.
#include "extern_template.h"
#include "indirect.h"
class IndirectClass;
void foo() {
ExternTemplateClass<IndirectClass> et;
}
#include "indirect.h"
class IndirectClass;
template <typename T>
class ExternTemplateClass {
public:
~ExternTemplateClass();
};
template <typename T>
ExternTemplateClass<T>::~ExternTemplateClass() {
T::StaticMethod();
}
extern template class ExternTemplateClass<IndirectClass>;
//template class ExternTemplateClass<IndirectClass>;
//===--- indirect.h - test input file for iwyu ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// This file is meant to be #included by "direct.h", which is directly
// #included by some .cc file. It provides an easy-to-access
// definition of a symbol that will cause an iwyu violation in a .cc
// file.
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_INDIRECT_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_INDIRECT_H_
class IndirectClass {
public:
void Method() const { };
int a;
static void StaticMethod() { };
static int statica;
};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_INDIRECT_H_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment