@@ -139,10 +139,8 @@ Annotator::Visibility Annotator::getVisibility(const clang::NamedDecl *decl)
139139 if (llvm::isa<clang::LabelDecl>(decl))
140140 return Visibility::Local;
141141
142- #if CLANG_VERSION_MAJOR >= 5
143142 if (llvm::isa<clang::CXXDeductionGuideDecl>(decl))
144143 return Visibility::Static; // Because it is not referenced in the AST anyway (FIXME)
145- #endif
146144
147145 clang::SourceManager &sm = getSourceMgr ();
148146 clang::FileID mainFID = sm.getMainFileID ();
@@ -263,13 +261,8 @@ void Annotator::registerInterestingDefinition(clang::SourceRange sourceRange,
263261
264262bool Annotator::generate (clang::Sema &Sema, bool WasInDatabase)
265263{
266- #if CLANG_VERSION_MAJOR >= 16
267264 static const std::string mp_suffix =
268265 llvm::sys::Process::GetEnv (" MULTIPROCESS_MODE" ).value_or (" " );
269- #else
270- static const std::string mp_suffix =
271- llvm::sys::Process::GetEnv (" MULTIPROCESS_MODE" ).getValueOr (" " );
272- #endif
273266
274267 std::ofstream fileIndex;
275268 fileIndex.open (projectManager.outputPrefix + " /fileIndex" + mp_suffix, std::ios::app);
@@ -294,15 +287,9 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
294287 continue ;
295288 done.insert (fn);
296289
297- auto project_it =
298- std::find_if (projectManager.projects .cbegin (), projectManager.projects .cend (),
299- [&fn](const ProjectInfo &it) {
300- #if CLANG_VERSION_MAJOR >= 16
301- return llvm::StringRef (fn).starts_with (it.name );
302- #else
303- return llvm::StringRef (fn).startswith (it.name );
304- #endif
305- });
290+ auto project_it = std::find_if (
291+ projectManager.projects .cbegin (), projectManager.projects .cend (),
292+ [&fn](const ProjectInfo &it) { return llvm::StringRef (fn).starts_with (it.name ); });
306293 if (project_it == projectManager.projects .cend ()) {
307294 std::cerr << " GENERATION ERROR: " << fn << " not in a project" << std::endl;
308295 continue ;
@@ -333,11 +320,10 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
333320 if (!projectinfo.revision .empty ())
334321 footer %= " revision <em>" % projectinfo.revision % " </em>" ;
335322
336- /* << " from file <a href='" << projectinfo.fileRepoUrl(filename) << "'>" <<
337- filename << "</a>" title=\"Arguments: << " << Generator::escapeAttr(args) <<"\"" */
323+ /* << " from file <a href='" << projectinfo.fileRepoUrl(filename) << "'>" <<
324+ filename << "</a>" title=\"Arguments: << " << Generator::escapeAttr(args) <<"\"" */
338325
339- // Emit the HTML.
340- #if CLANG_VERSION_MAJOR >= 12
326+ // Emit the HTML.
341327 const llvm::StringRef Buf = getSourceMgr ().getBufferData (FID);
342328 g.generate (projectManager.outputPrefix , projectManager.dataPath , fn, Buf.begin (), Buf.end (),
343329 footer,
@@ -346,17 +332,6 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
346332 " It may have many parsing errors." ,
347333 interestingDefinitionsInFile[FID]);
348334
349- #else
350- const llvm::MemoryBuffer *Buf = getSourceMgr ().getBuffer (FID);
351- g.generate (projectManager.outputPrefix , projectManager.dataPath , fn, Buf->getBufferStart (),
352- Buf->getBufferEnd (), footer,
353- WasInDatabase ? " "
354- : " Warning: That file was not part of the compilation database. "
355- " It may have many parsing errors." ,
356- interestingDefinitionsInFile[FID]);
357-
358- #endif
359-
360335 if (projectinfo.type == ProjectInfo::Normal)
361336 fileIndex << fn << ' \n ' ;
362337 }
@@ -368,11 +343,7 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
368343
369344 create_directories (llvm::Twine (projectManager.outputPrefix , " /refs/_M" ));
370345 for (const auto &it : references) {
371- #if CLANG_VERSION_MAJOR >= 16
372346 if (llvm::StringRef (it.first ).starts_with (" __builtin" ))
373- #else
374- if (llvm::StringRef (it.first ).startswith (" __builtin" ))
375- #endif
376347 continue ;
377348 if (it.first == " main" )
378349 continue ;
@@ -381,26 +352,14 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
381352 replace_invalid_filename_chars (refFilename);
382353
383354 std::string filename = projectManager.outputPrefix % " /refs/" % refFilename % mp_suffix;
384- #if CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR <= 5
385- std::string error;
386- llvm::raw_fd_ostream myfile (filename.c_str (), error, llvm::sys::fs::F_Append);
387- if (!error.empty ()) {
388- std::cerr << error << std::endl;
389- continue ;
390- }
391- #else
392355 std::error_code error_code;
393- #if CLANG_VERSION_MAJOR >= 13
394356 llvm::raw_fd_ostream myfile (filename, error_code, llvm::sys::fs::OF_Append);
395- #else
396- llvm::raw_fd_ostream myfile (filename, error_code, llvm::sys::fs::F_Append);
397- #endif
398357 if (error_code) {
399358 std::cerr << " Error writing ref file " << filename << " : " << error_code.message ()
400359 << std::endl;
401360 continue ;
402361 }
403- # endif
362+
404363 for (const auto &it2 : it.second ) {
405364 clang::SourceRange loc = it2.loc ;
406365 clang::SourceManager &sm = getSourceMgr ();
@@ -549,30 +508,16 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
549508 if (saved.find (idxRef) == std::string::npos) {
550509 std::string funcIndexFN =
551510 projectManager.outputPrefix % " /fnSearch/" % idx % mp_suffix;
552- #if CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR <= 5
553- std::string error;
554- llvm::raw_fd_ostream funcIndexFile (funcIndexFN.c_str (), error,
555- llvm::sys::fs::F_Append);
556- if (!error.empty ()) {
557- std::cerr << error << std::endl;
558- return false ;
559- }
560- #else
511+
561512 std::error_code error_code;
562- #if CLANG_VERSION_MAJOR >= 13
563513 llvm::raw_fd_ostream funcIndexFile (funcIndexFN, error_code,
564514 llvm::sys::fs::OF_Append);
565- #else
566- llvm::raw_fd_ostream funcIndexFile (funcIndexFN, error_code,
567- llvm::sys::fs::F_Append);
568- #endif
569515
570516 if (error_code) {
571517 std::cerr << " Error writing index file " << funcIndexFN << " : "
572518 << error_code.message () << std::endl;
573519 continue ;
574520 }
575- #endif
576521 funcIndexFile << fnIt.second << ' |' << fnIt.first << ' \n ' ;
577522 saved.append (idxRef); // include \0;
578523 }
@@ -1082,36 +1027,21 @@ std::pair<std::string, std::string> Annotator::getReferenceAndTitle(clang::Named
10821027
10831028 std::string qualName = getQualifiedName (decl);
10841029 if (llvm::isa<clang::FunctionDecl>(decl)
1085- #if CLANG_VERSION_MAJOR >= 5
10861030 // We can't mangle a deduction guide (also there is no need since it is not referenced)
10871031 && !llvm::isa<clang::CXXDeductionGuideDecl>(decl)
1088- #endif
10891032 && mangle->shouldMangleDeclName (decl)
1090- // workaround crash in clang while trying to mangle some builtin types
1091- #if CLANG_VERSION_MAJOR >= 16
1033+ // workaround crash in clang while trying to mangle some builtin types
10921034 && !llvm::StringRef (qualName).starts_with (" __" )) {
1093- #else
1094- && !llvm::StringRef (qualName).startswith (" __" )) {
1095- #endif
10961035 llvm::raw_string_ostream s (cached.first );
10971036 if (llvm::isa<clang::CXXDestructorDecl>(decl)) {
1098- #if CLANG_VERSION_MAJOR >= 11
10991037 mangle->mangleName (clang::GlobalDecl (llvm::cast<clang::CXXDestructorDecl>(decl),
11001038 clang::Dtor_Complete),
11011039 s);
1102- #else
1103- mangle->mangleCXXDtor (llvm::cast<clang::CXXDestructorDecl>(decl),
1104- clang::Dtor_Complete, s);
1105- #endif
1040+
11061041 } else if (llvm::isa<clang::CXXConstructorDecl>(decl)) {
1107- #if CLANG_VERSION_MAJOR >= 11
11081042 mangle->mangleName (clang::GlobalDecl (llvm::cast<clang::CXXConstructorDecl>(decl),
11091043 clang::Ctor_Complete),
11101044 s);
1111- #else
1112- mangle->mangleCXXCtor (llvm::cast<clang::CXXConstructorDecl>(decl),
1113- clang::Ctor_Complete, s);
1114- #endif
11151045 } else {
11161046 mangle->mangleName (decl, s);
11171047 }
@@ -1207,22 +1137,13 @@ void Annotator::syntaxHighlight(Generator &generator, clang::FileID FID, clang::
12071137
12081138 const clang::Preprocessor &PP = Sema.getPreprocessor ();
12091139 const clang::SourceManager &SM = getSourceMgr ();
1210- # if CLANG_VERSION_MAJOR >= 16
1140+
12111141 const auto FromFile = SM.getBufferOrNone (FID);
12121142 if (!FromFile.has_value ()) {
12131143 return ;
12141144 }
12151145 Lexer L (FID, *FromFile, SM, getLangOpts ());
1216- #elif CLANG_VERSION_MAJOR >= 12
1217- const llvm::Optional<llvm::MemoryBufferRef> FromFile = SM.getBufferOrNone (FID);
1218- if (!FromFile.hasValue ()) {
1219- return ;
1220- }
1221- Lexer L (FID, FromFile.getValue (), SM, getLangOpts ());
1222- #else
1223- const llvm::MemoryBuffer *FromFile = SM.getBuffer (FID);
1224- Lexer L (FID, FromFile, SM, getLangOpts ());
1225- #endif
1146+
12261147 const char *BufferStart = FromFile->getBufferStart ();
12271148 const char *BufferEnd = FromFile->getBufferEnd ();
12281149
0 commit comments