Skip to content

-ftime-trace incorrect header hierarchy when a header contains a template function for his last symbol #56554

@galop1n

Description

@galop1n

Using the repro case below, you will observe in the traces that 2.h shows up as an inclusion under 1.h instead of being an inclusion of main/cpp. The addition of a dummy forward declaration at the end of 1.h is a workaround to the problem and will yield the correct result with 2.h being under main.cpp. In both case, 3.h remains under 2.h accordingly.

  • main.cpp
#include "1.h"
#include "2.h"
int foo();
  • 1.h
#pragma once
#include <vector>
struct LARGE {};
template <typename T> auto Zero() -> T { return T{}; }
#if defined GUARD
struct guard;
#endif
  • 2.h
#pragma once
#include "3.h"
#include <map>
struct Bla {};
  • 3.h
#pragma once
#include <algorithm>
struct Foo {};

To produce the incorrect time trace : clang -ftime-trace main.cpp -c -o main-wrong.o
To produce the correct time trace : clang -DGUARD -ftime-trace main.cpp -c -o main-right.o

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions