我在LLVM CallGraph上使用scc_iterator。
以下是我如何得到CallGraph:
private var msgComposeMode: MessageComposeMode = .newMessage
private var arrangedMessages = [Any]()
@IBOutlet weak var Textview: GrowingTextView!
@IBOutlet weak var Tblview: UITableView!
@IBAction func sendReplyMessage_Action() {
if Textview.text.trimmedString().characters.count == 0 {
return
}
sendReplyMessage()
print("sendreply")
}
private func sendReplyMessage() {
guard
let toName = self.userNameToUseForChat,
let fromName = ChatAppAuthManager.shared.userName,
let orgID = ChatAppAuthManager.shared.orgId
else { return }
Textview.resignFirstResponder()
var msgParams: JSONDictionary = [
"fromUser": fromName,
"toUser": toName,
"orgId": orgID,
"msg": Textview.text,
"osType": "iOS",
]
var otherChatInfo = JSONDictionary()
otherChatInfo["messageType"] = "text"
otherChatInfo["isViewed"] = false
otherChatInfo["length"] = Textview.text.characters.count
msgParams["otherChatInfo"] = otherChatInfo
if msgComposeMode == MessageComposeMode.newMessage {
view?.showProgress(withMessage: "Sending...")
SocketClient.shared.replyToChatMessage(parameter: msgParams) { [weak self] theMessage in
self?.arrangedMessages.append(theMessage)
self?.Tblview.reloadData()
self?.showMostRecentMessage(with: false)
self?.view?.hideProgress()
}
} else if msgComposeMode == MessageComposeMode.editingMessage {
var editedMessage = nil as replyChatMessage?
for case let msg as replyChatMessage in self.arrangedMessages {
if msg.isSeelcted {
editedMessage = msg
break
}
}
msgParams["chatId"] = editedMessage?.id
editedMessage?.msg = Textview.text
SocketClient.shared.updateChatMessage(parameter: msgParams)
arrangedMessages[editedMessage!.messageIndex] = editedMessage!
Tblview?.reloadData()
view?.hideProgress()
msgComposeMode = .newMessage
}
Textview.text = ""
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("count")
return arrangedMessages.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let msg: Any = arrangedMessages[indexPath.row]
var theMessage: replyChatMessage?
if let theMessage = msg as? replyChatMessage {
if (theMessage.otherChatInfo?.messageType ?? "text") == replyChatMessage.MessageType.text.rawValue {
theMessage.messageIndex = indexPath.row
if theMessage.wasMessageSent(to: userNameToUseForChat) {
let senderCell = Tblview.dequeueReusableCell(
withIdentifier: MessageSenderCell.stringRepresentation
) as! MessageSenderCell
senderCell.show(reply: theMessage)
senderCell.didLongPress = { [unowned self] in
if let selectedMsg = self.isAnyMessageSelected() {
if selectedMsg.id != theMessage.id {
return
}
}
theMessage.isSeelcted.toggle()
self.arrangedMessages[theMessage.messageIndex] = theMessage
self.isMessagesSelected = theMessage.isSeelcted
self.Tblview?.reloadData()
}
senderCell.backgroundColor = theMessage.isSeelcted ? selectedCellColor : UIColor.clear
return senderCell
}
let receiverCell = Tblview.dequeueReusableCell(
withIdentifier: MessageReceiverCell.stringRepresentation
) as! MessageReceiverCell
receiverCell.show(reply: theMessage)
receiverCell.didLongPress = { [unowned self] in
if let selectedMsg = self.isAnyMessageSelected() {
if selectedMsg.id != theMessage.id {
return
}
}
theMessage.isSeelcted.toggle()
self.arrangedMessages[theMessage.messageIndex] = theMessage
self.isMessagesSelected = theMessage.isSeelcted
self.Tblview?.reloadData()
}
receiverCell.backgroundColor = theMessage.isSeelcted ? selectedCellColor : UIColor.clear
return receiverCell
} else if theMessage.otherChatInfo?.messageType == replyChatMessage.MessageType.image.rawValue {
let theCell = Tblview.dequeueReusableCell(
withIdentifier: MediaCell.stringRepresentation
) as! MediaCell
theCell.showData(reply : theMessage)
theCell.didLongPress = { [unowned self] in
if let selectedMsg: replyChatMessage = self.isAnyMessageSelected() {
if selectedMsg.id != theMessage.id {
return
}
}
theMessage.isSeelcted.toggle()
self.arrangedMessages[theMessage.messageIndex] = theMessage
self.isMessagesSelected = theMessage.isSeelcted
self.Tblview?.reloadData()
}
theCell.backgroundColor = theMessage.isSeelcted ? selectedCellColor : UIColor.clear
return theCell
} else {
return UITableViewCell(
style: UITableViewCellStyle.default,
reuseIdentifier: "cell"
)
}
} else {
let theCell = Tblview.dequeueReusableCell(
withIdentifier: MessageDateCell.stringRepresentation
) as! MessageDateCell
theCell.messageDate = msg as? String
return theCell
}
}
}
这导致了段错误:
CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
CG.dump();
这些是我注册的通行证:
scc_iterator<CallGraph*> SCCI = scc_begin(&CG)
附加说明: 当我转储callGraph时,我得到了这个:
legacy::PassManager passManager;
passManager.add(new llvm::CallGraphWrapperPass);
passManager.add(new me::myPass);
答案 0 :(得分:0)
我正在使用llvm 4.0。升级到llvm 5.0似乎正在起作用。