2013-07-23 00:36:58 +08:00
|
|
|
//===--- VirtualFileHelper.h ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-07-23 00:36:58 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// This file defines an utility class for tests that needs a source
|
2013-07-23 00:36:58 +08:00
|
|
|
/// manager for a virtual file with customizable content.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-09-05 03:15:54 +08:00
|
|
|
#ifndef CLANG_MODERNIZE_VIRTUAL_FILE_HELPER_H
|
|
|
|
#define CLANG_MODERNIZE_VIRTUAL_FILE_HELPER_H
|
2013-07-23 00:36:58 +08:00
|
|
|
|
|
|
|
#include "clang/Basic/Diagnostic.h"
|
|
|
|
#include "clang/Basic/DiagnosticOptions.h"
|
|
|
|
#include "clang/Basic/FileManager.h"
|
|
|
|
#include "clang/Basic/SourceManager.h"
|
|
|
|
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Class that provides easy access to a SourceManager and that allows to
|
2013-07-23 00:36:58 +08:00
|
|
|
/// map virtual files conveniently.
|
|
|
|
class VirtualFileHelper {
|
|
|
|
struct VirtualFile {
|
2013-08-27 22:50:26 +08:00
|
|
|
std::string FileName;
|
|
|
|
std::string Code;
|
2013-07-23 00:36:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
VirtualFileHelper()
|
|
|
|
: DiagOpts(new DiagnosticOptions()),
|
|
|
|
Diagnostics(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
|
|
|
|
&*DiagOpts),
|
|
|
|
DiagnosticPrinter(llvm::outs(), &*DiagOpts),
|
|
|
|
Files((FileSystemOptions())) {}
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Create a virtual file \p FileName, with content \p Code.
|
2013-07-23 00:36:58 +08:00
|
|
|
void mapFile(llvm::StringRef FileName, llvm::StringRef Code) {
|
|
|
|
VirtualFile VF = { FileName, Code };
|
|
|
|
VirtualFiles.push_back(VF);
|
|
|
|
}
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Create a new \c SourceManager with the virtual files and contents
|
2013-07-23 00:36:58 +08:00
|
|
|
/// mapped to it.
|
|
|
|
SourceManager &getNewSourceManager() {
|
|
|
|
Sources.reset(new SourceManager(Diagnostics, Files));
|
2013-08-27 22:50:26 +08:00
|
|
|
mapVirtualFiles(*Sources);
|
|
|
|
return *Sources;
|
|
|
|
}
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Map the virtual file contents in the given \c SourceManager.
|
2013-08-27 22:50:26 +08:00
|
|
|
void mapVirtualFiles(SourceManager &SM) const {
|
|
|
|
for (llvm::SmallVectorImpl<VirtualFile>::const_iterator
|
|
|
|
I = VirtualFiles.begin(),
|
|
|
|
E = VirtualFiles.end();
|
2013-07-23 00:36:58 +08:00
|
|
|
I != E; ++I) {
|
2014-08-28 04:03:22 +08:00
|
|
|
std::unique_ptr<llvm::MemoryBuffer> Buf =
|
|
|
|
llvm::MemoryBuffer::getMemBuffer(I->Code);
|
2013-08-27 22:50:26 +08:00
|
|
|
const FileEntry *Entry = SM.getFileManager().getVirtualFile(
|
2013-07-23 00:36:58 +08:00
|
|
|
I->FileName, Buf->getBufferSize(), /*ModificationTime=*/0);
|
2014-08-28 04:54:50 +08:00
|
|
|
SM.overrideFileContents(Entry, std::move(Buf));
|
2013-07-23 00:36:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
|
|
|
|
DiagnosticsEngine Diagnostics;
|
|
|
|
TextDiagnosticPrinter DiagnosticPrinter;
|
|
|
|
FileManager Files;
|
|
|
|
// most tests don't need more than one file
|
|
|
|
llvm::SmallVector<VirtualFile, 1> VirtualFiles;
|
2014-03-09 17:24:40 +08:00
|
|
|
std::unique_ptr<SourceManager> Sources;
|
2013-07-23 00:36:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace clang
|
|
|
|
|
2013-09-05 03:15:54 +08:00
|
|
|
#endif // CLANG_MODERNIZE_VIRTUAL_FILE_HELPER_H
|