mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-28 02:37:37 +00:00
522478d2c0
llvm commonly adds a comment to the closing brace of a namespace to indicate which namespace is closed. clang-tidy provides with llvm-namespace-comment a handy tool to check for this habit. We use it to ensure we consitently use namespace comments in Polly. There are slightly different styles in how namespaces are closed in LLVM. As there is no large difference between the different comment styles we go for the style clang-tidy suggests by default. To reproduce this fix run: for i in `ls tools/polly/lib/*/*.cpp`; \ clang-tidy -checks='-*,llvm-namespace-comment' -p build $i -fix \ -header-filter=".*"; \ done This cleanup was suggested by Eugene Zelenko <eugene.zelenko@gmail.com> in http://reviews.llvm.org/D21488 and was split out to increase readability. llvm-svn: 273621
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
//=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Helper function for extracting region debug information.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
#include "polly/Support/ScopLocation.h"
|
|
#include "llvm/Analysis/RegionInfo.h"
|
|
#include "llvm/IR/BasicBlock.h"
|
|
#include "llvm/IR/DebugInfo.h"
|
|
#include "llvm/IR/DebugLoc.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace polly {
|
|
|
|
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
|
|
std::string &FileName) {
|
|
LineBegin = -1;
|
|
LineEnd = 0;
|
|
|
|
for (const BasicBlock *BB : R->blocks())
|
|
for (const Instruction &Inst : *BB) {
|
|
DebugLoc DL = Inst.getDebugLoc();
|
|
if (!DL)
|
|
continue;
|
|
|
|
auto *Scope = cast<DIScope>(DL.getScope());
|
|
|
|
if (FileName.empty())
|
|
FileName = Scope->getFilename();
|
|
|
|
unsigned NewLine = DL.getLine();
|
|
|
|
LineBegin = std::min(LineBegin, NewLine);
|
|
LineEnd = std::max(LineEnd, NewLine);
|
|
}
|
|
}
|
|
} // namespace polly
|