'clang: What does emitting mean?
The clang diagnostics reference uses the word emit three times. The following warnings use this term.
Example 1: Compile this with -Wunneeded-internal-declaration
-Wunneeded-member-function
:
namespace {
int x;
int F();
struct A {
void M();
};
}
decltype(x) global1;
decltype(F()) global2;
decltype(&A::M) global3;
You get the following warnings:
warning: variable 'x' is not needed and will not be emitted
warning: function 'F' is not needed and will not be emitted
warning: member function 'M' is not needed and will not be emitted
Example 2: Compile this with -Wweak-vtables
:
class Apple {
virtual ~Apple() {}
};
You get the following warning:
warning: 'Apple' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit
Question
What does emitting mean?
The most straightforward explanation would be: emitting = generating assembly code. But there are some open questions, if we examine the details.
- In example 1 if we do not use
x
,F
andA::M
in unevaluated context, the warnings disappear. So the warning has to do something with unevaluated context. - In example 1
F
andM
are only declarations. Compiler never generates assembly code from a function declaration. So there is no point in giving a warning about it. - Clang has separate warnings for the case when a variable or function can be proven not to be used. Compile with
-Wunused
(example). No assembly code is generated from the variable and the function, and the warnings do not use the term emit. - The warnings that come from
-Wunused
are reported for definitions and not declarations.
I do not fully understand example 2. I put it here for the sake of completeness. Emitting might mean a slightly different thing here.
Could someone, maybe a clang contributor give some clarification about these questions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|