================
@@ -6048,13 +6048,23 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo
&CallInfo,
if (getDebugInfo() && TargetDecl && TargetDecl->hasAttr<MSAllocatorAttr>())
getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy->getPointeeType(), Loc);
- // Add metadata if calling an __attribute__((error(""))) or warning fn.
- if (TargetDecl && TargetDecl->hasAttr<ErrorAttr>()) {
- llvm::ConstantInt *Line =
- llvm::ConstantInt::get(Int64Ty, Loc.getRawEncoding());
- llvm::ConstantAsMetadata *MD = llvm::ConstantAsMetadata::get(Line);
- llvm::MDTuple *MDT = llvm::MDNode::get(getLLVMContext(), {MD});
- CI->setMetadata("srcloc", MDT);
+ // Add srcloc metadata for [[gnu::error/warning]] diagnostics.
+ // When ShowInliningChain is enabled, also track inline/static calls for the
+ // heuristic fallback when debug info is not available.
+ if (TargetDecl) {
+ bool NeedSrcLoc = TargetDecl->hasAttr<ErrorAttr>();
----------------
JustinStitt wrote:
AFAICT, `ErrorAttr` holds information about whether it is a warning or an
error, two modes of the same attr.
Attrs.inc:5179
```c
class CLANG_ABI ErrorAttr : public InheritableAttr {
unsigned userDiagnosticLength;
char *userDiagnostic;
public:
enum Spelling {
GNU_error = 0,
CXX11_gnu_error = 1,
C23_gnu_error = 2,
GNU_warning = 3,
CXX11_gnu_warning = 4,
C23_gnu_warning = 5,
SpellingNotCalculated = 15
...
```
and it can look into these spellings with
```c
bool isWarning() const { return getAttributeSpellingListIndex() == 3 ||
getAttributeSpellingListIndex() == 4 ||
getAttributeSpellingListIndex() == 5; }
```
I can't find a `WarningAttr` proper
https://github.com/llvm/llvm-project/pull/174892
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits