r347888 - [analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__
Kristof Umann via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 29 09:09:41 PST 2018
Author: szelethus
Date: Thu Nov 29 09:09:41 2018
New Revision: 347888
URL: http://llvm.org/viewvc/llvm-project?rev=347888&view=rev
Log:
[analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__
Differential Revision: https://reviews.llvm.org/D52986
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=347888&r1=347887&r2=347888&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Thu Nov 29 09:09:41 2018
@@ -962,41 +962,62 @@ static MacroNameAndArgs getMacroNameAndA
// CALL_FN(someFunctionName(param1, param2))
// we will find tok::l_paren, tok::r_paren, and tok::comma that do not divide
// actual macro arguments, or do not represent the macro argument's closing
- // parentheses, so we'll count how many parentheses aren't closed yet.
+ // parantheses, so we'll count how many parantheses aren't closed yet.
+ // If ParanthesesDepth
+ // * = 0, then there are no more arguments to lex.
+ // * = 1, then if we find a tok::comma, we can start lexing the next arg.
+ // * > 1, then tok::comma is a part of the current arg.
int ParenthesesDepth = 1;
+ // If we encounter __VA_ARGS__, we will lex until the closing tok::r_paren,
+ // even if we lex a tok::comma and ParanthesesDepth == 1.
+ const IdentifierInfo *__VA_ARGS__II = PP.getIdentifierInfo("__VA_ARGS__");
+
for (const IdentifierInfo *UnexpArgII : MacroArgs) {
MacroArgMap::mapped_type ExpandedArgTokens;
- // Lex the first token of the next macro parameter.
- RawLexer.LexFromRawLexer(TheTok);
-
- while (TheTok.isNot(tok::comma) || ParenthesesDepth != 1) {
- assert(TheTok.isNot(tok::eof) &&
- "EOF encountered while looking for expanded macro args!");
-
- if (TheTok.is(tok::l_paren))
- ++ParenthesesDepth;
-
- if (TheTok.is(tok::r_paren))
- --ParenthesesDepth;
+ // One could also simply not supply a single argument to __VA_ARGS__ -- this
+ // results in a preprocessor warning, but is not an error:
+ // #define VARIADIC(ptr, ...) \
+ // someVariadicTemplateFunction(__VA_ARGS__)
+ //
+ // int *ptr;
+ // VARIADIC(ptr); // Note that there are no commas, this isn't just an
+ // // empty parameter -- there are no parameters for '...'.
+ // In any other case, ParenthesesDepth mustn't be 0 here.
+ if (ParenthesesDepth != 0) {
- if (ParenthesesDepth == 0)
- break;
-
- if (TheTok.is(tok::raw_identifier))
- PP.LookUpIdentifierInfo(TheTok);
-
- ExpandedArgTokens.push_back(TheTok);
+ // Lex the first token of the next macro parameter.
RawLexer.LexFromRawLexer(TheTok);
+
+ while (!(ParenthesesDepth == 1 &&
+ (UnexpArgII == __VA_ARGS__II ? false : TheTok.is(tok::comma)))) {
+ assert(TheTok.isNot(tok::eof) &&
+ "EOF encountered while looking for expanded macro args!");
+
+ if (TheTok.is(tok::l_paren))
+ ++ParenthesesDepth;
+
+ if (TheTok.is(tok::r_paren))
+ --ParenthesesDepth;
+
+ if (ParenthesesDepth == 0)
+ break;
+
+ if (TheTok.is(tok::raw_identifier))
+ PP.LookUpIdentifierInfo(TheTok);
+
+ ExpandedArgTokens.push_back(TheTok);
+ RawLexer.LexFromRawLexer(TheTok);
+ }
+ } else {
+ assert(UnexpArgII == __VA_ARGS__II);
}
Args.emplace(UnexpArgII, std::move(ExpandedArgTokens));
}
- // TODO: The condition really should be TheTok.is(tok::r_paren), but variadic
- // macro arguments are not handled yet.
- assert(TheTok.isOneOf(tok::r_paren, tok::comma) &&
+ assert(TheTok.is(tok::r_paren) &&
"Expanded macro argument acquisition failed! After the end of the loop"
" this token should be ')'!");
Modified: cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist?rev=347888&r1=347887&r2=347888&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist (original)
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist Thu Nov 29 09:09:41 2018
@@ -4217,7 +4217,7 @@
<key>file</key><integer>0</integer>
</dict>
<key>name</key><string>VARIADIC_SET_TO_NULL</string>
- <key>expansion</key><string>ptr = nullptr; variadicFunc( 1)</string>
+ <key>expansion</key><string>ptr = nullptr; variadicFunc( 1, 5, "haha!")</string>
</dict>
</array>
<key>description</key><string>Dereference of null pointer (loaded from variable 'ptr')</string>
@@ -4257,12 +4257,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>333</integer>
+ <key>line</key><integer>324</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>333</integer>
+ <key>line</key><integer>324</integer>
<key>col</key><integer>5</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4270,12 +4270,181 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>327</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>327</integer>
+ <key>col</key><integer>22</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ </dict>
+ </array>
+ </dict>
+ <dict>
+ <key>kind</key><string>event</string>
+ <key>location</key>
+ <dict>
+ <key>line</key><integer>327</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <key>ranges</key>
+ <array>
+ <array>
+ <dict>
+ <key>line</key><integer>327</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>327</integer>
+ <key>col</key><integer>27</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ </array>
+ <key>depth</key><integer>0</integer>
+ <key>extended_message</key>
+ <string>Null pointer value stored to 'ptr'</string>
+ <key>message</key>
+ <string>Null pointer value stored to 'ptr'</string>
+ </dict>
+ <dict>
+ <key>kind</key><string>control</string>
+ <key>edges</key>
+ <array>
+ <dict>
+ <key>start</key>
+ <array>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ <key>end</key>
+ <array>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>8</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>8</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ </dict>
+ </array>
+ </dict>
+ <dict>
+ <key>kind</key><string>event</string>
+ <key>location</key>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>8</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <key>ranges</key>
+ <array>
+ <array>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>4</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>6</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ </array>
+ <key>depth</key><integer>0</integer>
+ <key>extended_message</key>
+ <string>Dereference of null pointer (loaded from variable 'ptr')</string>
+ <key>message</key>
+ <string>Dereference of null pointer (loaded from variable 'ptr')</string>
+ </dict>
+ </array>
+ <key>macro_expansions</key>
+ <array>
+ <dict>
+ <key>location</key>
+ <dict>
+ <key>line</key><integer>327</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <key>name</key><string>VARIADIC_SET_TO_NULL</string>
+ <key>expansion</key><string>ptr = nullptr; variadicFunc()</string>
+ </dict>
+ </array>
+ <key>description</key><string>Dereference of null pointer (loaded from variable 'ptr')</string>
+ <key>category</key><string>Logic error</string>
+ <key>type</key><string>Dereference of null pointer</string>
+ <key>check_name</key><string>core.NullDereference</string>
+ <!-- This hash is experimental and going to change! -->
+ <key>issue_hash_content_of_line_in_context</key><string>6aa30fd6a1e997027333f16c2064d973</string>
+ <key>issue_context_kind</key><string>function</string>
+ <key>issue_context</key><string>variadicMacroArgumentWithoutAnyArgumentTest</string>
+ <key>issue_hash_function_offset</key><string>5</string>
+ <key>location</key>
+ <dict>
+ <key>line</key><integer>328</integer>
+ <key>col</key><integer>8</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <key>ExecutedLines</key>
+ <dict>
+ <key>0</key>
+ <array>
+ <integer>323</integer>
+ <integer>324</integer>
+ <integer>327</integer>
+ <integer>328</integer>
+ </array>
+ </dict>
+ </dict>
+ <dict>
+ <key>path</key>
+ <array>
+ <dict>
+ <key>kind</key><string>control</string>
+ <key>edges</key>
+ <array>
+ <dict>
+ <key>start</key>
+ <array>
+ <dict>
+ <key>line</key><integer>343</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>343</integer>
+ <key>col</key><integer>5</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ </array>
+ <key>end</key>
+ <array>
+ <dict>
+ <key>line</key><integer>344</integer>
+ <key>col</key><integer>3</integer>
+ <key>file</key><integer>0</integer>
+ </dict>
+ <dict>
+ <key>line</key><integer>344</integer>
<key>col</key><integer>30</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4287,7 +4456,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>344</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4295,12 +4464,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>344</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>344</integer>
<key>col</key><integer>45</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4320,12 +4489,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4333,12 +4502,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4350,7 +4519,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4358,12 +4527,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>4</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>6</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4381,7 +4550,7 @@
<dict>
<key>location</key>
<dict>
- <key>line</key><integer>334</integer>
+ <key>line</key><integer>344</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4400,7 +4569,7 @@
<key>issue_hash_function_offset</key><string>3</string>
<key>location</key>
<dict>
- <key>line</key><integer>335</integer>
+ <key>line</key><integer>345</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4408,10 +4577,10 @@
<dict>
<key>0</key>
<array>
- <integer>332</integer>
- <integer>333</integer>
- <integer>334</integer>
- <integer>335</integer>
+ <integer>342</integer>
+ <integer>343</integer>
+ <integer>344</integer>
+ <integer>345</integer>
</array>
</dict>
</dict>
@@ -4426,12 +4595,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>347</integer>
+ <key>line</key><integer>357</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>347</integer>
+ <key>line</key><integer>357</integer>
<key>col</key><integer>5</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4439,12 +4608,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>11</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4456,7 +4625,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4464,12 +4633,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>23</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4489,12 +4658,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4502,12 +4671,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4519,7 +4688,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4527,12 +4696,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>4</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>6</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4550,7 +4719,7 @@
<dict>
<key>location</key>
<dict>
- <key>line</key><integer>348</integer>
+ <key>line</key><integer>358</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4569,7 +4738,7 @@
<key>issue_hash_function_offset</key><string>3</string>
<key>location</key>
<dict>
- <key>line</key><integer>349</integer>
+ <key>line</key><integer>359</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4577,10 +4746,10 @@
<dict>
<key>0</key>
<array>
- <integer>346</integer>
- <integer>347</integer>
- <integer>348</integer>
- <integer>349</integer>
+ <integer>356</integer>
+ <integer>357</integer>
+ <integer>358</integer>
+ <integer>359</integer>
</array>
</dict>
</dict>
@@ -4595,12 +4764,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>5</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4608,12 +4777,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>18</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>43</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4625,7 +4794,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>18</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4633,12 +4802,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>18</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>396</integer>
+ <key>line</key><integer>406</integer>
<key>col</key><integer>49</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4654,7 +4823,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>391</integer>
+ <key>line</key><integer>401</integer>
<key>col</key><integer>1</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4672,12 +4841,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>391</integer>
+ <key>line</key><integer>401</integer>
<key>col</key><integer>1</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>391</integer>
+ <key>line</key><integer>401</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4685,12 +4854,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>21</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4702,7 +4871,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4710,12 +4879,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>27</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4733,7 +4902,7 @@
<dict>
<key>location</key>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4752,7 +4921,7 @@
<key>issue_hash_function_offset</key><string>1</string>
<key>location</key>
<dict>
- <key>line</key><integer>392</integer>
+ <key>line</key><integer>402</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4760,10 +4929,10 @@
<dict>
<key>0</key>
<array>
- <integer>391</integer>
- <integer>392</integer>
- <integer>395</integer>
- <integer>396</integer>
+ <integer>401</integer>
+ <integer>402</integer>
+ <integer>405</integer>
+ <integer>406</integer>
</array>
</dict>
</dict>
@@ -4778,12 +4947,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>411</integer>
+ <key>line</key><integer>421</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>411</integer>
+ <key>line</key><integer>421</integer>
<key>col</key><integer>5</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4791,12 +4960,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>25</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4808,7 +4977,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4816,12 +4985,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>67</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4841,12 +5010,12 @@
<key>start</key>
<array>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4854,12 +5023,12 @@
<key>end</key>
<array>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4871,7 +5040,7 @@
<key>kind</key><string>event</string>
<key>location</key>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4879,12 +5048,12 @@
<array>
<array>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>4</integer>
<key>file</key><integer>0</integer>
</dict>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>6</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4902,7 +5071,7 @@
<dict>
<key>location</key>
<dict>
- <key>line</key><integer>412</integer>
+ <key>line</key><integer>422</integer>
<key>col</key><integer>3</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4921,7 +5090,7 @@
<key>issue_hash_function_offset</key><string>3</string>
<key>location</key>
<dict>
- <key>line</key><integer>413</integer>
+ <key>line</key><integer>423</integer>
<key>col</key><integer>8</integer>
<key>file</key><integer>0</integer>
</dict>
@@ -4929,10 +5098,10 @@
<dict>
<key>0</key>
<array>
- <integer>410</integer>
- <integer>411</integer>
- <integer>412</integer>
- <integer>413</integer>
+ <integer>420</integer>
+ <integer>421</integer>
+ <integer>422</integer>
+ <integer>423</integer>
</array>
</dict>
</dict>
Modified: cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp?rev=347888&r1=347887&r2=347888&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp (original)
+++ cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp Thu Nov 29 09:09:41 2018
@@ -317,9 +317,19 @@ void variadicMacroArgumentTest() {
*ptr = 5; // expected-warning{{Dereference of null pointer}}
}
-// TODO: Should correctly display the rest of the parameters.
// CHECK: <key>name</key><string>VARIADIC_SET_TO_NULL</string>
-// CHECK-NEXT: <key>expansion</key><string>ptr = nullptr; variadicFunc( 1)</string>
+// CHECK-NEXT: <key>expansion</key><string>ptr = nullptr; variadicFunc( 1, 5, "haha!")</string>
+
+void variadicMacroArgumentWithoutAnyArgumentTest() {
+ int *ptr;
+ // Not adding a single parameter to ... is silly (and also causes a
+ // preprocessor warning), but is not an excuse to crash on it.
+ VARIADIC_SET_TO_NULL(ptr);
+ *ptr = 5; // expected-warning{{Dereference of null pointer}}
+}
+
+// CHECK: <key>name</key><string>VARIADIC_SET_TO_NULL</string>
+// CHECK-NEXT: <key>expansion</key><string>ptr = nullptr; variadicFunc()</string>
//===----------------------------------------------------------------------===//
// Tests for # and ##.
More information about the cfe-commits
mailing list