Incorporate suggestions by Daniel Dunbar after his review. Thanks Daniel!
authorKevin Enderby <enderby@apple.com>
Mon, 4 Oct 2010 20:17:24 +0000 (20:17 +0000)
committerKevin Enderby <enderby@apple.com>
Mon, 4 Oct 2010 20:17:24 +0000 (20:17 +0000)
1) Changed ValidateDwarfFileNumber() to isValidDwarfFileNumber() to be better
   named.  Since it is just a predicate and isn't actually changing any state.

2) Added a missing return in the comments for setCurrentDwarfLoc() in
   include/llvm/MC/MCContext.h for fix formatting.

3) Changed clearDwarfLocSeen() to ClearDwarfLocSeen() since it does change
   state.

4) Simplified the last test in isValidDwarfFileNumber() to just a one line
   boolean test of MCDwarfFiles[FileNumber] != 0 for the final return statement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115551 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
lib/MC/MCContext.cpp
lib/MC/MCDwarf.cpp
lib/MC/MCParser/AsmParser.cpp

index c2dfb8fa7c49c2a2722365925ab972ee5feb0859..5ddbdae85d43a7d8b1a0ad4be52239274ba19b54 100644 (file)
@@ -160,7 +160,7 @@ namespace llvm {
     /// GetDwarfFile - creates an entry in the dwarf file and directory tables.
     unsigned GetDwarfFile(StringRef FileName, unsigned FileNumber);
 
-    bool ValidateDwarfFileNumber(unsigned FileNumber);
+    bool isValidDwarfFileNumber(unsigned FileNumber);
 
     bool hasDwarfFiles(void) {
       return MCDwarfFiles.size() != 0;
@@ -177,7 +177,8 @@ namespace llvm {
     }
 
     /// setCurrentDwarfLoc - saves the information from the currently parsed
-    /// dwarf .loc directive and sets DwarfLocSeen.  When the next instruction      /// is assembled an entry in the line number table with this information and
+    /// dwarf .loc directive and sets DwarfLocSeen.  When the next instruction
+    /// is assembled an entry in the line number table with this information and
     /// the address of the instruction will be created.
     void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
                             unsigned Flags, unsigned Isa) {
@@ -188,7 +189,7 @@ namespace llvm {
       CurrentDwarfLoc.setIsa(Isa);
       DwarfLocSeen = true;
     }
-    void clearDwarfLocSeen() { DwarfLocSeen = false; }
+    void ClearDwarfLocSeen() { DwarfLocSeen = false; }
 
     bool getDwarfLocSeen() { return DwarfLocSeen; }
     const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
index 1e65f877924db65fa476cbd27fac7297e34ee33d..9c747d10417286961dc5ddb0eb1a897a749fc670 100644 (file)
@@ -255,15 +255,11 @@ unsigned MCContext::GetDwarfFile(StringRef FileName, unsigned FileNumber) {
   return FileNumber;
 }
 
-/// ValidateDwarfFileNumber - takes a dwarf file number and returns true if it
+/// isValidDwarfFileNumber - takes a dwarf file number and returns true if it
 /// currently is assigned and false otherwise.
-bool MCContext::ValidateDwarfFileNumber(unsigned FileNumber) {
+bool MCContext::isValidDwarfFileNumber(unsigned FileNumber) {
   if(FileNumber == 0 || FileNumber >= MCDwarfFiles.size())
     return false;
 
-  MCDwarfFile *&ExistingFile = MCDwarfFiles[FileNumber];
-  if (ExistingFile)
-    return true;
-  else
-    return false;
+  return MCDwarfFiles[FileNumber] != 0;
 }
index faa2df0ae95cea97d4e39d390f92ce82bc6f6589..17d164f2c7b628f7bc8f40ad0fd2ad81930678d2 100644 (file)
@@ -76,7 +76,7 @@ void MCLineEntry::Make(MCObjectStreamer *MCOS, const MCSection *Section) {
   MCLineEntry LineEntry(LineSym, DwarfLoc);
 
   // clear DwarfLocSeen saying the current .loc info is now used.
-  MCOS->getContext().clearDwarfLocSeen();
+  MCOS->getContext().ClearDwarfLocSeen();
 
   // Get the MCLineSection for this section, if one does not exist for this
   // section create it.
index 688827d2c76917c0f181e8757aca11e8940b69a7..974e4ab0a64742c1b7fee69eef591f0b8de969a5 100644 (file)
@@ -2031,7 +2031,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
   int64_t FileNumber = getTok().getIntVal();
   if (FileNumber < 1)
     return TokError("file number less than one in '.loc' directive");
-  if (!getContext().ValidateDwarfFileNumber(FileNumber))
+  if (!getContext().isValidDwarfFileNumber(FileNumber))
     return TokError("unassigned file number in '.loc' directive");
   Lex();