[llvm-commits] Tentative header modifications to resolve Bugzilla 11257 (unnecessary "Unused parameter" warnings)

Eli Friedman eli.friedman at gmail.com
Fri Nov 4 11:15:07 PDT 2011


On Mon, Oct 31, 2011 at 1:22 PM, Harris, Kevin <Kevin.Harris at unisys.com> wrote:
> At Eli's request, I'm submitting my tentative edits for resolving the compile warnings for 4 headers.  In effect, this is an attachment to Bugzilla 11257, which reports "Unused parameter" warnings for these 4 headers, when compiled with gcc 4.5.3, using "-Wall -Wextra -Wshadow" compilation warnings options.
>
> I make no claim to the desirability of these particular edits, other than the fact that they resolve the warnings in a way that is semantically innocuous and results in little or no compilation performance impact after optimization.
>
> Note that the first edit to the first of these 4 files is actually intended to fix a "shadow" warning in the same file (see Bugzilla 11256) rather than an "Unused parameter" warning.

I applied a variant of this to fix the -Wunused-parameter warnings in r143715.

-Eli

>        -Kevin
>
> Index: llvm/rc1/include/llvm/Analysis/CFGPrinter.h
> ===================================================================
> --- llvm/rc1/include/llvm/Analysis/CFGPrinter.h (revision 143139)
> +++ llvm/rc1/include/llvm/Analysis/CFGPrinter.h (working copy)
> @@ -26,7 +26,7 @@
>  template<>
>  struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
>
> -  DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
> +  DOTGraphTraits (bool isSimple1=false) : DefaultDOTGraphTraits(isSimple1) {}
>
>   static std::string getGraphName(const Function *F) {
>     return "CFG for '" + F->getNameStr() + "' function";
> @@ -41,7 +41,7 @@
>     raw_string_ostream OS(Str);
>
>     WriteAsOperand(OS, Node, false);
> -    return OS.str();
> +    if (Graph == NULL) {return OS.str();} else {return OS.str();}
>   }
>
>   static std::string getCompleteNodeLabel(const BasicBlock *Node,
> @@ -69,7 +69,7 @@
>         --i;
>       }
>
> -    return OutStr;
> +      if (Graph == NULL) {return OutStr;} else {return OutStr;}
>   }
>
>   std::string getNodeLabel(const BasicBlock *Node,
>
> Index: llvm/rc1/include/llvm/Assembly/AssemblyAnnotationWriter.h
> ===================================================================
> --- llvm/rc1/include/llvm/Assembly/AssemblyAnnotationWriter.h   (revision 143139)
> +++ llvm/rc1/include/llvm/Assembly/AssemblyAnnotationWriter.h   (working copy)
> @@ -33,29 +33,37 @@
>   /// emitFunctionAnnot - This may be implemented to emit a string right before
>   /// the start of a function.
>   virtual void emitFunctionAnnot(const Function *F,
> -                                 formatted_raw_ostream &OS) {}
> +                                 formatted_raw_ostream &OS) {
> +    if (F == NULL || OS.DELETE_STREAM) return;
> +  }
>
>   /// emitBasicBlockStartAnnot - This may be implemented to emit a string right
>   /// after the basic block label, but before the first instruction in the
>   /// block.
>   virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
>                                         formatted_raw_ostream &OS) {
> +    if (BB == NULL || OS.DELETE_STREAM) return;
>   }
>
>   /// emitBasicBlockEndAnnot - This may be implemented to emit a string right
>   /// after the basic block.
>   virtual void emitBasicBlockEndAnnot(const BasicBlock *BB,
>                                       formatted_raw_ostream &OS) {
> +    if (BB == NULL || OS.DELETE_STREAM) return;
>   }
>
>   /// emitInstructionAnnot - This may be implemented to emit a string right
>   /// before an instruction is emitted.
>   virtual void emitInstructionAnnot(const Instruction *I,
> -                                    formatted_raw_ostream &OS) {}
> +                                    formatted_raw_ostream &OS) {
> +    if (I == NULL || OS.DELETE_STREAM) return;
> +  }
>
>   /// printInfoComment - This may be implemented to emit a comment to the
>   /// right of an instruction or global value.
> -  virtual void printInfoComment(const Value &V, formatted_raw_ostream &OS) {}
> +  virtual void printInfoComment(const Value &V, formatted_raw_ostream &OS) {
> +    if (V.hasName() || OS.DELETE_STREAM) return;
> +  }
>  };
>
>  } // End llvm namespace
>
> Index: llvm/rc1/include/llvm/ExecutionEngine/JITEventListener.h
> ===================================================================
> --- llvm/rc1/include/llvm/ExecutionEngine/JITEventListener.h    (revision 143139)
> +++ llvm/rc1/include/llvm/ExecutionEngine/JITEventListener.h    (working copy)
> @@ -61,7 +61,9 @@
>   /// if you should happen to need that.
>   virtual void NotifyFunctionEmitted(const Function &F,
>                                      void *Code, size_t Size,
> -                                     const EmittedFunctionDetails &Details) {}
> +                                     const EmittedFunctionDetails &Details) {
> +    if (F.isNullValue() || Code == NULL || Size == 0 || Details.MF == NULL) return;
> +  }
>
>   /// NotifyFreeingMachineCode - Called from freeMachineCodeForFunction(), after
>   /// the global mapping is removed, but before the machine code is returned to
> @@ -71,7 +73,9 @@
>   /// parameter to a previous NotifyFunctionEmitted call.  The Function passed
>   /// to NotifyFunctionEmitted may have been destroyed by the time of the
>   /// matching NotifyFreeingMachineCode call.
> -  virtual void NotifyFreeingMachineCode(void *OldPtr) {}
> +  virtual void NotifyFreeingMachineCode(void *OldPtr) {
> +      if (OldPtr == NULL) return;
> +  }
>  };
>
>  // This returns NULL if support isn't available.
>
> Index: llvm/rc1/include/llvm/Support/DOTGraphTraits.h
> ===================================================================
> --- llvm/rc1/include/llvm/Support/DOTGraphTraits.h      (revision 143139)
> +++ llvm/rc1/include/llvm/Support/DOTGraphTraits.h      (working copy)
> @@ -62,7 +62,7 @@
>   /// isNodeHidden - If the function returns true, the given node is not
>   /// displayed in the graph.
>   static bool isNodeHidden(const void *Node) {
> -    return false;
> +      if (Node == NULL) {return false;} else {return false;}
>   }
>
>   /// getNodeLabel - Given a node and a pointer to the top level graph, return
> @@ -127,13 +127,13 @@
>   /// numEdgeDestLabels - If hasEdgeDestLabels, this function returns the
>   /// number of incoming edge labels the given node has.
>   static unsigned numEdgeDestLabels(const void *Node) {
> -    return 0;
> +      if (Node == NULL) {return 0;} else {return 0;}
>   }
>
>   /// getEdgeDestLabel - If hasEdgeDestLabels, this function returns the
>   /// incoming edge label with the given index in the given node.
>   static std::string getEdgeDestLabel(const void *Node, unsigned i) {
> -    return "";
> +      if (Node == NULL || i == 0) {return "";} else {return "";}
>   }
>
>   /// addCustomGraphFeatures - If a graph is made up of more than just
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list