Skip to content

Commit e7d53e8

Browse files
committed
Do not produce prototypes for FuncDecl outside sketch source code
1 parent 1f730a1 commit e7d53e8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: ArduinoDiagnosticConsumer.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "ArduinoDiagnosticConsumer.hpp"
3333
#include "CommandLine.hpp"
3434
#include "JsonImpl.hpp"
35+
#include "utils.hpp"
3536

3637
using namespace clang;
3738

@@ -56,6 +57,13 @@ void ArduinoDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level level,
5657
outs() << presumedFilename << ") ";
5758
}
5859

60+
if (!cStrEndsWith(presumedFilename, ".ino")) {
61+
if (debugOutput) {
62+
outs() << "Ignoring non .ino source file\n";
63+
}
64+
return;
65+
}
66+
5967
unsigned id = info.getID();
6068
if (id == 3441 || id == 3442 /* use of undeclared identifier */) {
6169
// It seems that the only way to retrieve the undeclared symbol

Diff for: utils.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,16 @@ inline bool startsWith(const string &in, const string &prefix) {
6262
int l = prefix.length();
6363
return in.find(prefix.c_str(), 0, l) == 0;
6464
}
65+
66+
inline bool cStrEndsWith(const char *str, const char *suffix) {
67+
if (str == NULL || suffix == NULL)
68+
return false;
69+
70+
size_t strLen = strlen(str);
71+
size_t suffixLen = strlen(suffix);
72+
73+
if (suffixLen > strLen)
74+
return false;
75+
76+
return strncmp(str + strLen - suffixLen, suffix, suffixLen) == 0;
77+
}

0 commit comments

Comments
 (0)