llvm-project/clang/docs
Roman Lebedev 377748fd7b [clang][Parse] Diagnose useless null statements / empty init-statements
Summary:
clang has `-Wextra-semi` (D43162), which is not dictated by the currently selected standard.
While that is great, there is at least one more source of need-less semis - 'null statements'.
Sometimes, they are needed:
```
for(int x = 0; continueToDoWork(x); x++)
  ; // Ugly code, but the semi is needed here.
```

But sometimes they are just there for no reason:
```
switch(X) {
case 0:
  return -2345;
case 5:
  return 0;
default:
  return 42;
}; // <- oops

;;;;;;;;;;; <- OOOOPS, still not diagnosed. Clearly this is junk.
```

Additionally:
```
if(; // <- empty init-statement
   true)
  ;

switch (; // empty init-statement
        x) {
  ...
}

for (; // <- empty init-statement
     int y : S())
  ;
}

As usual, things may or may not go sideways in the presence of macros.
While evaluating this diag on my codebase of interest, it was unsurprisingly
discovered that Google Test macros are *very* prone to this.
And it seems many issues are deep within the GTest itself, not
in the snippets passed from the codebase that uses GTest.

So after some thought, i decided not do issue a diagnostic if the semi
is within *any* macro, be it either from the normal header, or system header.

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]]

Reviewers: rsmith, aaron.ballman, efriedma

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52695

llvm-svn: 347339
2018-11-20 18:59:05 +00:00
..
CommandGuide Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
analyzer [analyzer] Add a testing facility for testing relationships between symbols. 2018-09-25 23:50:53 +00:00
tools Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
AddressSanitizer.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
AttributeReference.rst
AutomaticReferenceCounting.rst Fix and improve the ARC spec's wording about unmanaged objects. 2018-07-20 05:40:09 +00:00
Block-ABI-Apple.rst [CodeGen][ObjC] Make copying and disposing of a non-escaping block 2018-07-20 17:10:32 +00:00
Block-ABI-Apple.txt Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
BlockLanguageSpec.rst
CMakeLists.txt docs: Fix Sphinx detection with out-of-tree builds 2017-05-09 01:42:33 +00:00
ClangCheck.rst [clang docs] Minor fix in ClangCheck.rst 2016-11-14 17:31:24 +00:00
ClangCommandLineReference.rst Change -fsanitize-address-poison-class-member-array-new-cookie to -fsanitize-address-poison-custom-array-cookie 2018-11-02 17:29:04 +00:00
ClangFormat.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ClangFormatStyleOptions.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ClangPlugins.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ClangTools.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ControlFlowIntegrity.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ControlFlowIntegrityDesign.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
CrossCompilation.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
DataFlowSanitizer.rst
DataFlowSanitizerDesign.rst
DiagnosticsReference.rst [Diagnostic] Fix a warning typo. NFC. 2018-09-12 18:27:21 +00:00
DriverArchitecture.png
DriverInternals.rst
ExternalClangExamples.rst Add LibreOffice Clang plugin to ExternalClangExamples.rst 2017-03-22 08:45:49 +00:00
FAQ.rst
HardwareAssistedAddressSanitizerDesign.rst [docs] Don't use the `asm` syntax highlighting (which our docs builder 2018-08-06 01:28:42 +00:00
HowToSetupToolingForLLVM.rst Allow the creation of human-friendly ASTDumper to arbitrary output stream 2018-04-06 13:01:12 +00:00
InternalsManual.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
IntroductionToTheClangAST.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ItaniumMangleAbiTags.rst NFC fix documentation build by rL263015 2016-03-09 19:39:16 +00:00
JSONCompilationDatabase.rst [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found. 2017-11-09 10:37:39 +00:00
LTOVisibility.rst Implement CFI for indirect calls via a member function pointer. 2018-06-26 02:15:47 +00:00
LanguageExtensions.rst Update the documentation for attribute feature tests. 2018-11-20 15:23:07 +00:00
LeakSanitizer.rst [docs] Update LeakSanitizer documentation to reflect OS X support 2017-09-13 19:40:10 +00:00
LibASTMatchers.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
LibASTMatchersReference.html [ASTMatchers] overload ignoringParens for Expr 2018-11-09 20:54:06 +00:00
LibASTMatchersTutorial.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
LibFormat.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
LibTooling.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
MSVCCompatibility.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
Makefile.sphinx docs: Clarify that cfi-unrelated-cast is based on lifetime. 2016-02-01 18:55:50 +00:00
MemorySanitizer.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
Modules.rst [Modules] Add platform and environment features to requires clause 2018-09-18 17:11:13 +00:00
ObjectiveCLiterals.rst
OpenMPSupport.rst [OPENMP] What's new for OpenMP in clang. 2018-07-26 17:53:45 +00:00
PCHInternals.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
PCHLayout.graffle
PCHLayout.png
PTHInternals.rst
RAVFrontendAction.rst Port getLocStart -> getBeginLoc 2018-08-09 21:08:08 +00:00
README.txt
RefactoringEngine.rst Fix small nits in clang-refactor doc. 2017-10-10 09:00:56 +00:00
ReleaseNotes.rst [clang][Parse] Diagnose useless null statements / empty init-statements 2018-11-20 18:59:05 +00:00
SafeStack.rst [Docs] Update supported oses for safestack, ubsan, asan, tsan and msan 2018-07-25 13:55:06 +00:00
SanitizerCoverage.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
SanitizerSpecialCaseList.rst Allow specifying sanitizers in blacklists 2017-09-25 22:11:12 +00:00
SanitizerStats.rst [docs] -fsanitize=cfi only allowed with -fvisibility= 2018-06-15 23:11:18 +00:00
ShadowCallStack.rst [ShadowCallStack] fix the docs 2018-05-01 00:15:56 +00:00
SourceBasedCodeCoverage.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ThinLTO.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
ThreadSafetyAnalysis.rst Correct the attribute spelling for guarded_var and pt_guarded_var. 2017-05-08 12:39:17 +00:00
ThreadSanitizer.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
Toolchain.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
Tooling.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
UndefinedBehaviorSanitizer.rst Update our URLs in clang doc to use https 2018-11-04 17:02:00 +00:00
UsersManual.rst [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov (after revert https://reviews.llvm.org/rL346659) 2018-11-17 19:41:39 +00:00
conf.py Update docs version and clear release notes after 8.0.0 version bump 2018-08-01 14:01:27 +00:00
doxygen-mainpage.dox [docs] Add missing file 2016-03-03 10:44:10 +00:00
doxygen.cfg.in Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
index.rst Add the -fsanitize=shadow-call-stack flag 2018-04-03 22:33:53 +00:00
make.bat

README.txt

See llvm/docs/README.txt