Skip to content

Commit 84c3fca

Browse files
author
Simon Moll
committed
Merge remote-tracking branch 'necgh/develop' into hpce/merge_102020
2 parents 06b2f35 + 67de4af commit 84c3fca

File tree

11,461 files changed

+1095643
-326499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

11,461 files changed

+1095643
-326499
lines changed

.git-blame-ignore-revs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
3131

3232
# Remove line-endings added by r320089. NFC.
3333
100a0eedc00b2bf48bcdc6c209c000745a4a0e48
34+
35+
# Cleanup __config indention. NFC.
36+
2b772b930e097ed6f06d698a51e291c7fd318baa
37+
38+
# Fixing whitespace problems
39+
94b2dd0998230c758abd92c99d3700c971f7a31a
40+
41+
# Wiped out some non-ascii characters that snuck into the copyright.
42+
5b08a8a43254ed30bd953e869b0fd9fc1e8b82d0

clang-tools-extra/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
include(CMakeDependentOption)
22

3+
option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
4+
"Include static analyzer checks in clang-tidy" ON)
5+
36
add_subdirectory(clang-apply-replacements)
47
add_subdirectory(clang-reorder-fields)
58
add_subdirectory(modularize)

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,6 @@ bool conflictInNamespace(const ASTContext &AST, llvm::StringRef QualifiedSymbol,
324324
return false;
325325
}
326326

327-
AST_MATCHER(EnumDecl, isScoped) {
328-
return Node.isScoped();
329-
}
330-
331327
bool isTemplateParameter(TypeLoc Type) {
332328
while (!Type.isNull()) {
333329
if (Type.getTypeLocClass() == TypeLoc::SubstTemplateTypeParm)

clang-tools-extra/clang-tidy/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set(LLVM_LINK_COMPONENTS
33
Support
44
)
55

6+
configure_file(
7+
${CMAKE_CURRENT_SOURCE_DIR}/clang-tidy-config.h.cmake
8+
${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-config.h)
9+
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
10+
611
add_clang_library(clangTidy
712
ClangTidy.cpp
813
ClangTidyCheck.cpp
@@ -34,7 +39,7 @@ clang_target_link_libraries(clangTidy
3439
clangToolingCore
3540
)
3641

37-
if(CLANG_ENABLE_STATIC_ANALYZER)
42+
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
3843
clang_target_link_libraries(clangTidy
3944
PRIVATE
4045
clangStaticAnalyzerCore
@@ -46,6 +51,7 @@ endif()
4651
# If you add a check, also add it to ClangTidyForceLinker.h in this directory.
4752
add_subdirectory(android)
4853
add_subdirectory(abseil)
54+
add_subdirectory(altera)
4955
add_subdirectory(boost)
5056
add_subdirectory(bugprone)
5157
add_subdirectory(cert)
@@ -59,7 +65,7 @@ add_subdirectory(llvm)
5965
add_subdirectory(llvmlibc)
6066
add_subdirectory(misc)
6167
add_subdirectory(modernize)
62-
if(CLANG_ENABLE_STATIC_ANALYZER)
68+
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
6369
add_subdirectory(mpi)
6470
endif()
6571
add_subdirectory(objc)
@@ -71,6 +77,7 @@ add_subdirectory(zircon)
7177
set(ALL_CLANG_TIDY_CHECKS
7278
clangTidyAndroidModule
7379
clangTidyAbseilModule
80+
clangTidyAlteraModule
7481
clangTidyBoostModule
7582
clangTidyBugproneModule
7683
clangTidyCERTModule
@@ -91,7 +98,7 @@ set(ALL_CLANG_TIDY_CHECKS
9198
clangTidyReadabilityModule
9299
clangTidyZirconModule
93100
)
94-
if(CLANG_ENABLE_STATIC_ANALYZER)
101+
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
95102
list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyMPIModule)
96103
endif()
97104
set(ALL_CLANG_TIDY_CHECKS ${ALL_CLANG_TIDY_CHECKS} PARENT_SCOPE)

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#include "ClangTidyModuleRegistry.h"
2121
#include "ClangTidyProfiling.h"
2222
#include "ExpandModularHeadersPPCallbacks.h"
23+
#include "clang-tidy-config.h"
2324
#include "clang/AST/ASTConsumer.h"
2425
#include "clang/AST/ASTContext.h"
2526
#include "clang/AST/Decl.h"
2627
#include "clang/ASTMatchers/ASTMatchFinder.h"
27-
#include "clang/Config/config.h"
2828
#include "clang/Format/Format.h"
2929
#include "clang/Frontend/ASTConsumers.h"
3030
#include "clang/Frontend/CompilerInstance.h"
@@ -47,10 +47,10 @@
4747
#include <algorithm>
4848
#include <utility>
4949

50-
#if CLANG_ENABLE_STATIC_ANALYZER
50+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
5151
#include "clang/Analysis/PathDiagnostic.h"
5252
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
53-
#endif // CLANG_ENABLE_STATIC_ANALYZER
53+
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
5454

5555
using namespace clang::ast_matchers;
5656
using namespace clang::driver;
@@ -63,7 +63,7 @@ namespace clang {
6363
namespace tidy {
6464

6565
namespace {
66-
#if CLANG_ENABLE_STATIC_ANALYZER
66+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
6767
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
6868

6969
class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
@@ -95,7 +95,7 @@ class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
9595
private:
9696
ClangTidyContext &Context;
9797
};
98-
#endif // CLANG_ENABLE_STATIC_ANALYZER
98+
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
9999

100100
class ErrorReporter {
101101
public:
@@ -110,6 +110,9 @@ class ErrorReporter {
110110
DiagOpts->ShowColors = Context.getOptions().UseColor.getValueOr(
111111
llvm::sys::Process::StandardOutHasColors());
112112
DiagPrinter->BeginSourceFile(LangOpts);
113+
if (DiagOpts->ShowColors && !llvm::sys::Process::StandardOutIsDisplayed()) {
114+
llvm::sys::Process::UseANSIEscapeCodes(true);
115+
}
113116
}
114117

115118
SourceManager &getSourceManager() { return SourceMgr; }
@@ -324,7 +327,7 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
324327
}
325328
}
326329

327-
#if CLANG_ENABLE_STATIC_ANALYZER
330+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
328331
static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
329332
AnalyzerOptionsRef AnalyzerOptions) {
330333
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
@@ -369,7 +372,7 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
369372
}
370373
return List;
371374
}
372-
#endif // CLANG_ENABLE_STATIC_ANALYZER
375+
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
373376

374377
std::unique_ptr<clang::ASTConsumer>
375378
ClangTidyASTConsumerFactory::CreateASTConsumer(
@@ -424,7 +427,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
424427
if (!Checks.empty())
425428
Consumers.push_back(Finder->newASTConsumer());
426429

427-
#if CLANG_ENABLE_STATIC_ANALYZER
430+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
428431
AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
429432
AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
430433
Context, Context.canEnableAnalyzerAlphaCheckers());
@@ -440,7 +443,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
440443
new AnalyzerDiagnosticConsumer(Context));
441444
Consumers.push_back(std::move(AnalysisConsumer));
442445
}
443-
#endif // CLANG_ENABLE_STATIC_ANALYZER
446+
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
444447
return std::make_unique<ClangTidyASTConsumer>(
445448
std::move(Consumers), std::move(Profiling), std::move(Finder),
446449
std::move(Checks));
@@ -453,11 +456,11 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
453456
CheckNames.emplace_back(CheckFactory.getKey());
454457
}
455458

456-
#if CLANG_ENABLE_STATIC_ANALYZER
459+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
457460
for (const auto &AnalyzerCheck : getAnalyzerCheckersAndPackages(
458461
Context, Context.canEnableAnalyzerAlphaCheckers()))
459462
CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
460-
#endif // CLANG_ENABLE_STATIC_ANALYZER
463+
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
461464

462465
llvm::sort(CheckNames);
463466
return CheckNames;

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,8 @@ static bool IsNOLINTFound(StringRef NolintDirectiveText, StringRef Line,
305305

306306
static llvm::Optional<StringRef> getBuffer(const SourceManager &SM, FileID File,
307307
bool AllowIO) {
308-
// This is similar to the implementation of SourceManager::getBufferData(),
309-
// but uses ContentCache::getRawBuffer() rather than getBuffer() if
310-
// AllowIO=false, to avoid triggering file I/O if the file contents aren't
311-
// already mapped.
312-
bool CharDataInvalid = false;
313-
const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(File, &CharDataInvalid);
314-
if (CharDataInvalid || !Entry.isFile())
315-
return llvm::None;
316-
const SrcMgr::ContentCache *Cache = Entry.getFile().getContentCache();
317-
const llvm::MemoryBuffer *Buffer =
318-
AllowIO ? Cache->getBuffer(SM.getDiagnostics(), SM.getFileManager(),
319-
SourceLocation(), &CharDataInvalid)
320-
: Cache->getRawBuffer();
321-
if (!Buffer || CharDataInvalid)
322-
return llvm::None;
323-
return Buffer->getBuffer();
308+
return AllowIO ? SM.getBufferDataOrNone(File)
309+
: SM.getBufferDataIfLoaded(File);
324310
}
325311

326312
static bool LineIsMarkedWithNOLINT(const SourceManager &SM, SourceLocation Loc,

clang-tools-extra/clang-tidy/ClangTidyForceLinker.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H
1111

12-
#include "clang/Config/config.h"
12+
#include "clang-tidy-config.h"
1313
#include "llvm/Support/Compiler.h"
1414

1515
namespace clang {
@@ -20,6 +20,11 @@ extern volatile int AbseilModuleAnchorSource;
2020
static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
2121
AbseilModuleAnchorSource;
2222

23+
// This anchor is used to force the linker to link the AlteraModule.
24+
extern volatile int AlteraModuleAnchorSource;
25+
static int LLVM_ATTRIBUTE_UNUSED AlteraModuleAnchorDestination =
26+
AlteraModuleAnchorSource;
27+
2328
// This anchor is used to force the linker to link the AndroidModule.
2429
extern volatile int AndroidModuleAnchorSource;
2530
static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
@@ -90,7 +95,7 @@ extern volatile int ModernizeModuleAnchorSource;
9095
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
9196
ModernizeModuleAnchorSource;
9297

93-
#if CLANG_ENABLE_STATIC_ANALYZER && \
98+
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER && \
9499
!defined(CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS)
95100
// This anchor is used to force the linker to link the MPIModule.
96101
extern volatile int MPIModuleAnchorSource;

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ template <> struct MappingTraits<FileFilter> {
4747
IO.mapRequired("name", File.Name);
4848
IO.mapOptional("lines", File.LineRanges);
4949
}
50-
static StringRef validate(IO &io, FileFilter &File) {
50+
static std::string validate(IO &io, FileFilter &File) {
5151
if (File.Name.empty())
5252
return "No file name specified";
5353
for (const FileFilter::LineRange &Range : File.LineRanges) {
5454
if (Range.first <= 0 || Range.second <= 0)
5555
return "Invalid line range";
5656
}
57-
return StringRef();
57+
return "";
5858
}
5959
};
6060

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
#include "clang/Lex/PreprocessorOptions.h"
1414
#include "clang/Serialization/ASTReader.h"
1515

16+
#define DEBUG_TYPE "clang-tidy"
17+
1618
namespace clang {
1719
namespace tooling {
1820

1921
class ExpandModularHeadersPPCallbacks::FileRecorder {
2022
public:
2123
/// Records that a given file entry is needed for replaying callbacks.
22-
void addNecessaryFile(const FileEntry *File) { FilesToRecord.insert(File); }
24+
void addNecessaryFile(const FileEntry *File) {
25+
// Don't record modulemap files because it breaks same file detection.
26+
if (!(File->getName().endswith("module.modulemap") ||
27+
File->getName().endswith("module.private.modulemap") ||
28+
File->getName().endswith("module.map") ||
29+
File->getName().endswith("module_private.map")))
30+
FilesToRecord.insert(File);
31+
}
2332

2433
/// Records content for a file and adds it to the FileSystem.
2534
void recordFileContent(const FileEntry *File,
@@ -30,22 +39,24 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
3039
return;
3140

3241
// FIXME: Why is this happening? We might be losing contents here.
33-
if (!ContentCache.getRawBuffer())
42+
llvm::Optional<StringRef> Data = ContentCache.getBufferDataIfLoaded();
43+
if (!Data)
3444
return;
3545

3646
InMemoryFs.addFile(File->getName(), /*ModificationTime=*/0,
37-
llvm::MemoryBuffer::getMemBufferCopy(
38-
ContentCache.getRawBuffer()->getBuffer()));
47+
llvm::MemoryBuffer::getMemBufferCopy(*Data));
3948
// Remove the file from the set of necessary files.
4049
FilesToRecord.erase(File);
4150
}
4251

4352
/// Makes sure we have contents for all the files we were interested in. Ideally
4453
/// `FilesToRecord` should be empty.
4554
void checkAllFilesRecorded() {
46-
for (auto FileEntry : FilesToRecord)
47-
llvm::errs() << "Did not record contents for input file: "
48-
<< FileEntry->getName() << "\n";
55+
LLVM_DEBUG({
56+
for (auto FileEntry : FilesToRecord)
57+
llvm::dbgs() << "Did not record contents for input file: "
58+
<< FileEntry->getName() << "\n";
59+
});
4960
}
5061

5162
private:

clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
106106
// Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
107107
// whether this already exists).
108108
Diagnostic << IncludeInserter.createIncludeInsertion(
109-
Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
110-
false);
109+
Source.getFileID(ComparisonExpr->getBeginLoc()),
110+
AbseilStringsMatchHeader);
111111
}
112112

113113
void StringFindStartswithCheck::registerPPCallbacks(
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===--- AlteraTidyModule.cpp - clang-tidy --------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "../ClangTidy.h"
10+
#include "../ClangTidyModule.h"
11+
#include "../ClangTidyModuleRegistry.h"
12+
#include "StructPackAlignCheck.h"
13+
14+
using namespace clang::ast_matchers;
15+
16+
namespace clang {
17+
namespace tidy {
18+
namespace altera {
19+
20+
class AlteraModule : public ClangTidyModule {
21+
public:
22+
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
23+
CheckFactories.registerCheck<StructPackAlignCheck>(
24+
"altera-struct-pack-align");
25+
}
26+
};
27+
28+
} // namespace altera
29+
30+
// Register the AlteraTidyModule using this statically initialized variable.
31+
static ClangTidyModuleRegistry::Add<altera::AlteraModule>
32+
X("altera-module", "Adds Altera FPGA OpenCL lint checks.");
33+
34+
// This anchor is used to force the linker to link in the generated object file
35+
// and thus register the AlteraModule.
36+
volatile int AlteraModuleAnchorSource = 0;
37+
38+
} // namespace tidy
39+
} // namespace clang
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set(LLVM_LINK_COMPONENTS
2+
FrontendOpenMP
3+
support
4+
)
5+
6+
add_clang_library(clangTidyAlteraModule
7+
AlteraTidyModule.cpp
8+
StructPackAlignCheck.cpp
9+
10+
LINK_LIBS
11+
clangTidy
12+
clangTidyUtils
13+
)
14+
15+
clang_target_link_libraries(clangTidyAlteraModule
16+
PRIVATE
17+
clangAnalysis
18+
clangAST
19+
clangASTMatchers
20+
clangBasic
21+
clangLex
22+
)

0 commit comments

Comments
 (0)