llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Sai Deepak Sana (saideepaksana)

<details>
<summary>Changes</summary>

For the issue #<!-- -->88882, 
files changed `clang/include/clang/Basic/DiagnosticLexKinds.td`, 
`clang/lib/Lex/PPDirectives.cpp`. I tried adding %0 place holder in the .td 
file, so by passing the identifier info of the redefined builtin macro, so now 
it says clearly which macro affected, before it was `warning: redefining 
builtin macro` and now it is `warning: redefining builtin macro '__FILE__'`. 

---
Full diff: https://github.com/llvm/llvm-project/pull/167299.diff


2 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+1-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+2-2) 


``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 417187222e448..e9339f473c67a 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -396,7 +396,7 @@ def pp_out_of_date_dependency : Warning<
   "current file is older than dependency %0">;
 def ext_pp_undef_builtin_macro : ExtWarn<"undefining builtin macro">,
   InGroup<BuiltinMacroRedefined>;
-def ext_pp_redef_builtin_macro : ExtWarn<"redefining builtin macro">,
+def ext_pp_redef_builtin_macro : ExtWarn<"redefining builtin macro '%0'">,
   InGroup<BuiltinMacroRedefined>;
 def pp_disabled_macro_expansion : Warning<
   "disabled expansion of recursive macro">, DefaultIgnore,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 891c8ab7f3155..38780f4fc9a89 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3289,7 +3289,7 @@ void Preprocessor::HandleDefineDirective(
       // Warn if defining "__LINE__" and other builtins, per C99 6.10.8/4 and
       // C++ [cpp.predefined]p4, but allow it as an extension.
       if (isLanguageDefinedBuiltin(SourceMgr, OtherMI, II->getName()))
-        Diag(MacroNameTok, diag::ext_pp_redef_builtin_macro);
+        Diag(MacroNameTok, diag::ext_pp_redef_builtin_macro) << 
MacroNameTok.getIdentifierInfo(); // inserting this diagonstic message into 
stream.
       // Macros must be identical.  This means all tokens and whitespace
       // separation must be the same.  C99 6.10.3p2.
       else if (!OtherMI->isAllowRedefinitionsWithoutWarning() &&
@@ -3354,7 +3354,7 @@ void Preprocessor::HandleUndefDirective() {
     // Warn if undefining "__LINE__" and other builtins, per C99 6.10.8/4 and
     // C++ [cpp.predefined]p4, but allow it as an extension.
     if (isLanguageDefinedBuiltin(SourceMgr, MI, II->getName()))
-      Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro);
+      Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro) << 
MacroNameTok.getIdentifierInfo(); // inserting this diagnostic message into it
 
     if (MI->isWarnIfUnused())
       WarnUnusedMacroLocs.erase(MI->getDefinitionLoc());

``````````

</details>


https://github.com/llvm/llvm-project/pull/167299
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to