llvm.org GIT mirror llvm / d7e2505
simplify some code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79121 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
1 changed file(s) with 13 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
9494 }
9595 SM.AddNewSourceBuffer(F, SMLoc());
9696
97 // Find all instances of CheckPrefix followed by : in the file. The
98 // MemoryBuffer is guaranteed to be nul terminated, but may have nul's
99 // embedded into it. We don't support check strings with embedded nuls.
100 std::string Prefix = CheckPrefix + ":";
97 // Find all instances of CheckPrefix followed by : in the file.
10198 const char *CurPtr = F->getBufferStart(), *BufferEnd = F->getBufferEnd();
10299
103100 while (1) {
104101 // See if Prefix occurs in the memory buffer.
105 const char *Ptr = FindFixedStringInBuffer(Prefix, CurPtr, *F);
102 const char *Ptr = FindFixedStringInBuffer(CheckPrefix, CurPtr, *F);
106103
107104 // If we didn't find a match, we're done.
108105 if (Ptr == BufferEnd)
109106 break;
110107
108 // Verify that the : is present after the prefix.
109 if (Ptr[CheckPrefix.size()] != ':') {
110 CurPtr = Ptr+1;
111 continue;
112 }
113
111114 // Okay, we found the prefix, yay. Remember the rest of the line, but
112115 // ignore leading and trailing whitespace.
113 Ptr += Prefix.size();
116 Ptr += CheckPrefix.size()+1;
117
114118 while (*Ptr == ' ' || *Ptr == '\t')
115119 ++Ptr;
116120
126130 // Check that there is something on the line.
127131 if (Ptr >= CurPtr) {
128132 SM.PrintMessage(SMLoc::getFromPointer(CurPtr),
129 "found empty check string with prefix '"+Prefix+"'",
133 "found empty check string with prefix '"+CheckPrefix+":'",
130134 "error");
131135 return true;
132136 }
137141 }
138142
139143 if (CheckStrings.empty()) {
140 errs() << "error: no check strings found with prefix '" << Prefix << "'\n";
144 errs() << "error: no check strings found with prefix '" << CheckPrefix
145 << ":'\n";
141146 return true;
142147 }
143148